I am trying to upload some files wtih different extensions like .png,.jpg,.txt,.pdf etc. to IIS server .However my all files are created to given path but they are all 1kb size and when you open them it says
The original file is in the temp folder. Full path of the file: C:\Temp\xxxxxxxxx.tmp
My code works perfectly on localhost when running from the source code and There is no such a folder on web server's directory like mentioned in the message.
My code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUploadTest.aspx.cs" Inherits="FileUploadTest" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" Multiple="Multiple" name="okantestfileupload" runat="server" />
<asp:Button ID="btnFileUpload" OnClick="btnFileUpload_Clickk" runat="server" Text="ekle" Width="150px" CssClass="CommandButton" />
<asp:ListBox runat="server" ID="ListBoxForInfo" Width="400" CssClass="NormaltextBox" ></asp:ListBox>
</div>
</form>
</body>
</html>
.cs part
protected void btnFileUpload_Clickk(object sender, EventArgs e)
{
string strFolder = @"D:\TEST\";
HttpFileCollection uploadedFiles = Request.Files;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile uploadedFile = Request.Files.Get(i);
var uFileSize = uploadedFile.ContentLength;
var uFileName = uploadedFile.FileName;
var uContentType = uploadedFile.ContentType;
string uExtension =
System.IO.Path.GetExtension(uploadedFile.FileName);
uploadedFile.SaveAs(strFolder + uFileName);
ListBoxForInfo.Items.Insert(0, uFileName + "." + uContentType + " Boyut: (" + uFileSize + " bytes) yüklendi.");
}
}
What should I do to fix that?I have already tried some solutions including taking consideration of antivirus programmes.
Regards