Änderungen Fileupload
This commit is contained in:
@@ -305,7 +305,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td colspan="5">
|
<td colspan="5">
|
||||||
<center>
|
<center>
|
||||||
<asp:LinkButton ID="btn_Save_Changes" runat="server" BackColor="#043381" BorderStyle="None" CausesValidation="true" CssClass="btn btn-btn-primary" OnClick="btn_Save_Changes_Click"><label style="color:#fff" for="btn_Save_Changes">Save Changes</label></asp:LinkButton>
|
<asp:LinkButton ID="btn_Save_Changes" runat="server" BackColor="#043381" BorderStyle="None" CausesValidation="true" CssClass="btn btn-btn-primary" OnClick="btn_Save_Changes_Click" OnClientClick="return ValidateFile_Desktop()"><label style="color:#fff" for="btn_Save_Changes">Save Changes</label></asp:LinkButton>
|
||||||
</center>
|
</center>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -386,9 +386,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5">
|
<td colspan="5">
|
||||||
|
|
||||||
|
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<div class="dropdown show">
|
<div class="dropdown show">
|
||||||
<a class="btn btn-primary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="width:182.217px;background-color:#003680;color:#fff"><center><img id="myImage" src="<%=flagpath%>../images/Logo_small.png" style="border:1px solid #fff;width:102px; justify-items:center;color:#043381;background-color:#fff" alt="Logo Schriftzug: Verag Spedition AG Blaue Schrift: Verag Spedition Graue Schrift: AG" /></center></a>
|
<a class="btn btn-primary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="width:182.217px;background-color:#003680;color:#fff"><center><img id="myImage" src="<%=flagpath%>../images/Logo_small.png" style="border:1px solid #fff;width:102px; justify-items:center;color:#043381;background-color:#fff" alt="Logo Schriftzug: Verag Spedition AG Blaue Schrift: Verag Spedition Graue Schrift: AG" /></center></a>
|
||||||
@@ -407,7 +405,7 @@
|
|||||||
<tr >
|
<tr >
|
||||||
<td colspan="5" style="height:35px">
|
<td colspan="5" style="height:35px">
|
||||||
<center>
|
<center>
|
||||||
<asp:LinkButton ID="LinkButton1" runat="server" BackColor="#043381" BorderStyle="None" CausesValidation="true" CssClass="btn btn-btn-primary" OnClick="LinkButton1_Click"><label style="color:#fff" for="btn_Save_Changes">Save Changes</label></asp:LinkButton>
|
<asp:LinkButton ID="LinkButton1" runat="server" BackColor="#043381" BorderStyle="None" CausesValidation="true" CssClass="btn btn-btn-primary" OnClick="LinkButton1_Click" OnClientClick="return ValidateFile_Mobile()"><label style="color:#fff" for="btn_Save_Changes">Save Changes</label></asp:LinkButton>
|
||||||
</center>
|
</center>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -433,5 +431,50 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.concat.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.concat.min.js"></script>
|
||||||
<script src="bootstrap-5.0.2-dist/js/bootstrap.min.js"></script>
|
<script src="bootstrap-5.0.2-dist/js/bootstrap.min.js"></script>
|
||||||
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var validFilesTypes = ["bmp", "gif", "png", "jpg", "jpeg", "doc", "xls"];
|
||||||
|
function ValidateFile_Desktop() {
|
||||||
|
var file = document.getElementById("<%=FileUpload_Desktop.ClientID%>");
|
||||||
|
var label = document.getElementById("<%=FileUpload_Desktop.ClientID%>");
|
||||||
|
var path = file.value;
|
||||||
|
var ext = path.substring(path.lastIndexOf(".") + 1, path.length).toLowerCase();
|
||||||
|
var isValidFile = false;
|
||||||
|
for (var i = 0; i < validFilesTypes.length; i++) {
|
||||||
|
if (ext == validFilesTypes[i]) {
|
||||||
|
isValidFile = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isValidFile) {
|
||||||
|
label.style.color = "red";
|
||||||
|
label.innerHTML = "Invalid File. Please upload a File with" +
|
||||||
|
" extension:\n\n" + validFilesTypes.join(", ");
|
||||||
|
}
|
||||||
|
return isValidFile;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var validFilesTypes = ["bmp", "gif", "png", "jpg", "jpeg", "doc", "xls"];
|
||||||
|
function ValidateFile_Mobile() {
|
||||||
|
var file = document.getElementById("<%=FileUpload_Mobile.ClientID%>");
|
||||||
|
var label = document.getElementById("<%=FileUpload_Mobile.ClientID%>");
|
||||||
|
var path = file.value;
|
||||||
|
var ext = path.substring(path.lastIndexOf(".") + 1, path.length).toLowerCase();
|
||||||
|
var isValidFile = false;
|
||||||
|
for (var i = 0; i < validFilesTypes.length; i++) {
|
||||||
|
if (ext == validFilesTypes[i]) {
|
||||||
|
isValidFile = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isValidFile) {
|
||||||
|
label.style.color = "red";
|
||||||
|
label.innerHTML = "Invalid File. Please upload a File with" +
|
||||||
|
" extension:\n\n" + validFilesTypes.join(", ");
|
||||||
|
}
|
||||||
|
return isValidFile;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2,20 +2,14 @@
|
|||||||
Partial Class login_CreateUser
|
Partial Class login_CreateUser
|
||||||
Inherits System.Web.UI.Page
|
Inherits System.Web.UI.Page
|
||||||
|
|
||||||
|
Protected Sub Page_Load(sender As Object, e As EventArgs)
|
||||||
Protected Sub FileUpload_Mobile_Init(sender As Object, e As EventArgs)
|
If Not User.Identity.IsAuthenticated Then
|
||||||
|
FormsAuthentication.RedirectToLoginPage()
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Protected Sub FileUpload_Desktop_Init(sender As Object, e As EventArgs)
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
|
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
|
||||||
Dim validFileTypes As String() = {"bmp", "gif", "png", "jpg", "jpeg", "doc", "xls"}
|
Dim validFileTypes As String() = {"bmp", "gif", "png", "jpg", "jpeg"}
|
||||||
Dim ext As String = System.IO.Path.GetExtension(FileUpload_Mobile.PostedFile.FileName)
|
Dim ext As String = System.IO.Path.GetExtension(FileUpload_Mobile.PostedFile.FileName)
|
||||||
Dim isValidFile As Boolean = False
|
Dim isValidFile As Boolean = False
|
||||||
For i As Integer = 0 To validFileTypes.Length - 1
|
For i As Integer = 0 To validFileTypes.Length - 1
|
||||||
@@ -35,11 +29,13 @@ Partial Class login_CreateUser
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Protected Sub btn_Save_Changes_Click(sender As Object, e As EventArgs)
|
Protected Sub btn_Save_Changes_Click(sender As Object, e As EventArgs)
|
||||||
Dim validFileTypes As String() = {"bmp", "gif", "png", "jpg", "jpeg", "doc", "xls"}
|
Dim validFileTypes As String() = {"bmp", "gif", "png", "jpg", "jpeg"}
|
||||||
Dim ext As String = System.IO.Path.GetExtension(FileUpload_Desktop.PostedFile.FileName)
|
Dim ext As String = System.IO.Path.GetExtension(FileUpload_Desktop.PostedFile.FileName)
|
||||||
Dim isValidFile As Boolean = False
|
Dim isValidFile As Boolean = False
|
||||||
|
Dim pathtosave As String = String.Empty
|
||||||
For i As Integer = 0 To validFileTypes.Length - 1
|
For i As Integer = 0 To validFileTypes.Length - 1
|
||||||
If ext = "." & validFileTypes(i) Then
|
If ext = "." & validFileTypes(i) Then
|
||||||
|
pathtosave = "../images/users/" + Me.Page.User.Identity.Name + "/ImageProf"
|
||||||
isValidFile = True
|
isValidFile = True
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
@@ -49,6 +45,7 @@ Partial Class login_CreateUser
|
|||||||
lbl_message_desktop.Text = "Invalid File. Please upload a File with extension " &
|
lbl_message_desktop.Text = "Invalid File. Please upload a File with extension " &
|
||||||
String.Join(",", validFileTypes)
|
String.Join(",", validFileTypes)
|
||||||
Else
|
Else
|
||||||
|
FileUpload_Desktop.PostedFile.SaveAs(pathtosave + "/" + Date.Now.ToShortDateString + "." + System.IO.Path.GetExtension(FileUpload_Desktop.PostedFile.FileName))
|
||||||
lbl_message_desktop.ForeColor = System.Drawing.Color.Green
|
lbl_message_desktop.ForeColor = System.Drawing.Color.Green
|
||||||
lbl_message_desktop.Text = "File uploaded successfully."
|
lbl_message_desktop.Text = "File uploaded successfully."
|
||||||
End If
|
End If
|
||||||
|
|||||||
Reference in New Issue
Block a user