upload and download file
-
niki_nilu wrote:
i want upload file on server.
Use FileUpload control.
niki_nilu wrote:
and how to download it.
Just redirect to that file.
Response.Redirect("FileName.extension");
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
niki_nilu wrote:
i want upload file on server.
Use FileUpload control.
niki_nilu wrote:
and how to download it.
Just redirect to that file.
Response.Redirect("FileName.extension");
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
hi yes i took input file control. but where i will see that uploaded file. my code is--
if (File1.PostedFile != null) //Checking for valid file
{
// Since the PostedFile.FileNameFileName gives the entire path we use Substring function to rip of the filename alone.
string StrFileName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string StrFileType = File1.PostedFile.ContentType;
int IntFileSize = File1.PostedFile.ContentLength;
//Checking for the length of the file. If length is 0 then file is not uploaded.
if (IntFileSize <= 0)
Response.Write("<font color='Red' size='2'>Uploading of file " + StrFileName + " failed </font>");
else
{
File1.PostedFile.SaveAs(Server.MapPath(".\\" + StrFileName));
Messagebox.Show("Your file was uploaded successfully");
//Response.Write("<font color='green' size='2'>Your file " + StrFileName + " of type " + StrFileType + " and size " + IntFileSize.ToString() + " bytes was uploaded successfully</font>");
}
}Gayatri
-
hi yes i took input file control. but where i will see that uploaded file. my code is--
if (File1.PostedFile != null) //Checking for valid file
{
// Since the PostedFile.FileNameFileName gives the entire path we use Substring function to rip of the filename alone.
string StrFileName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string StrFileType = File1.PostedFile.ContentType;
int IntFileSize = File1.PostedFile.ContentLength;
//Checking for the length of the file. If length is 0 then file is not uploaded.
if (IntFileSize <= 0)
Response.Write("<font color='Red' size='2'>Uploading of file " + StrFileName + " failed </font>");
else
{
File1.PostedFile.SaveAs(Server.MapPath(".\\" + StrFileName));
Messagebox.Show("Your file was uploaded successfully");
//Response.Write("<font color='green' size='2'>Your file " + StrFileName + " of type " + StrFileType + " and size " + IntFileSize.ToString() + " bytes was uploaded successfully</font>");
}
}Gayatri
-
hi yes i took input file control. but where i will see that uploaded file. my code is--
if (File1.PostedFile != null) //Checking for valid file
{
// Since the PostedFile.FileNameFileName gives the entire path we use Substring function to rip of the filename alone.
string StrFileName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string StrFileType = File1.PostedFile.ContentType;
int IntFileSize = File1.PostedFile.ContentLength;
//Checking for the length of the file. If length is 0 then file is not uploaded.
if (IntFileSize <= 0)
Response.Write("<font color='Red' size='2'>Uploading of file " + StrFileName + " failed </font>");
else
{
File1.PostedFile.SaveAs(Server.MapPath(".\\" + StrFileName));
Messagebox.Show("Your file was uploaded successfully");
//Response.Write("<font color='green' size='2'>Your file " + StrFileName + " of type " + StrFileType + " and size " + IntFileSize.ToString() + " bytes was uploaded successfully</font>");
}
}Gayatri
niki_nilu wrote:
but where i will see that uploaded file.
In the virtual directory of your web. :-O
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
hi yes i took input file control. but where i will see that uploaded file. my code is--
if (File1.PostedFile != null) //Checking for valid file
{
// Since the PostedFile.FileNameFileName gives the entire path we use Substring function to rip of the filename alone.
string StrFileName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string StrFileType = File1.PostedFile.ContentType;
int IntFileSize = File1.PostedFile.ContentLength;
//Checking for the length of the file. If length is 0 then file is not uploaded.
if (IntFileSize <= 0)
Response.Write("<font color='Red' size='2'>Uploading of file " + StrFileName + " failed </font>");
else
{
File1.PostedFile.SaveAs(Server.MapPath(".\\" + StrFileName));
Messagebox.Show("Your file was uploaded successfully");
//Response.Write("<font color='green' size='2'>Your file " + StrFileName + " of type " + StrFileType + " and size " + IntFileSize.ToString() + " bytes was uploaded successfully</font>");
}
}Gayatri
niki_nilu wrote:
if (File1.PostedFile != null)
If you are using ASp.NET file upload control use
File1.HasFile
niki_nilu wrote:
string StrFileName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string StrFileName = IO.Path.GetFileName(File1.PostedFile.FileName);
niki_nilu wrote:
but where i will see that uploaded file.
In the same place where you are uploading it :confused:
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions