shahab
Junior Contributor
Dear friends,
I had uploaded the sound files (Mp3, wav format) To an Upload center successfully.
What I had planed is something like this:
The Database I have planed only saves the name of the files that will upload by users
SqlParameter paramVoiceAddress = new SqlParameter(
"@VoiceAddress", SqlDbType.Char , 50);
paramVoiceAddress.Value = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf(@"\")+1);
objCmd.Parameters.Add(paramVoiceAddress);
--------------------------------------------------------------------------------------------------------------------
** The uploaded files will place in www root \Project name \Music\
void UploadVoiceFile()
{
if (File1.PostedFile != null)
{
try
{
string FileNameOnServer = @"D:\Inetpub\wwwroot\School\VoiceFiles\" + File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf(@"\")+1);
File1.PostedFile.SaveAs(FileNameOnServer);
Label3.Text = "Upload Successful!";
}
catch (Exception ex)
{
Label3.Text = "Error saving file <b>D:\\" +
File1.Value + "</b><br>" + ex.ToString();
}
}
}
--------------------------------------------------------------------------------------------------------------------
***
Now my questions are:
1- What is the best way to save files in MS Sql server (The file or its name?)
2- What is the best way to showing the uploaded files to users in order to download them without on problem? (Please suggest more than one way and compare the best ones!)
3- Are there any security issues on putting the music files directly in wwwroot?
4- When the user does not upload a file (It is possible Sending later) this message is shown:
System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\Inetpub\wwwroot\School\VoiceFiles\". at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at
So many thanks.
shahab
I had uploaded the sound files (Mp3, wav format) To an Upload center successfully.
What I had planed is something like this:
The Database I have planed only saves the name of the files that will upload by users
SqlParameter paramVoiceAddress = new SqlParameter(
"@VoiceAddress", SqlDbType.Char , 50);
paramVoiceAddress.Value = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf(@"\")+1);
objCmd.Parameters.Add(paramVoiceAddress);
--------------------------------------------------------------------------------------------------------------------
** The uploaded files will place in www root \Project name \Music\
void UploadVoiceFile()
{
if (File1.PostedFile != null)
{
try
{
string FileNameOnServer = @"D:\Inetpub\wwwroot\School\VoiceFiles\" + File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf(@"\")+1);
File1.PostedFile.SaveAs(FileNameOnServer);
Label3.Text = "Upload Successful!";
}
catch (Exception ex)
{
Label3.Text = "Error saving file <b>D:\\" +
File1.Value + "</b><br>" + ex.ToString();
}
}
}
--------------------------------------------------------------------------------------------------------------------
***
Now my questions are:
1- What is the best way to save files in MS Sql server (The file or its name?)
2- What is the best way to showing the uploaded files to users in order to download them without on problem? (Please suggest more than one way and compare the best ones!)
3- Are there any security issues on putting the music files directly in wwwroot?
4- When the user does not upload a file (It is possible Sending later) this message is shown:
System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\Inetpub\wwwroot\School\VoiceFiles\". at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at
So many thanks.
shahab