I'm working on upload exe file in c#
-
I got the source code but there is no output coming out. there is no any error too. can you please help me.. This is the source code I used in asp:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" style="z-index: 1; left: 420px; top: 315px; position: absolute; width: 285px; height: 22px" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg, file/exe" style="z-index: 1; left: 420px; top: 341px; position: absolute" />
<hr />
<asp:Label ID="lblSuccess" runat="server" ForeColor ="Red" style="z-index: 1; left: 518px; top: 344px; position: absolute" />c#:
foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
{string fileName = Path.GetFileName(postedFile.FileName); postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName); } lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count)
-
I got the source code but there is no output coming out. there is no any error too. can you please help me.. This is the source code I used in asp:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" style="z-index: 1; left: 420px; top: 315px; position: absolute; width: 285px; height: 22px" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg, file/exe" style="z-index: 1; left: 420px; top: 341px; position: absolute" />
<hr />
<asp:Label ID="lblSuccess" runat="server" ForeColor ="Red" style="z-index: 1; left: 518px; top: 344px; position: absolute" />c#:
foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
{string fileName = Path.GetFileName(postedFile.FileName); postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName); } lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count)
file/exe
is not the MIME type for executable files. It will most likely come through asapplication/octet-stream
, but it depends on the browser and the client OS. NB: Uploading executable files to the web server is rather dangerous. If you haven't configured your server properly, there's a possibility that the uploaded file could be executed on your server, which would be a major security vulnerability. How to configure uploads for IIS Web applications[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
file/exe
is not the MIME type for executable files. It will most likely come through asapplication/octet-stream
, but it depends on the browser and the client OS. NB: Uploading executable files to the web server is rather dangerous. If you haven't configured your server properly, there's a possibility that the uploaded file could be executed on your server, which would be a major security vulnerability. How to configure uploads for IIS Web applications[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thank you for your kind info. This is my company requirement to do so. I will discuss about it with the authority person. Thank You