This actually gives you path of the uploaded file.
But in all the newer browsers (FF 3.6 series, Chrome, IE7+) this feature has been disabled due to security reasons. Any website should not need path of a file stored in client's systems because that gives the directory structure and may expose other important
things to website owner.
So in your case, the above code returned only the file name.
Please mark the replies as answers if they help or unmark if not.
Christos83
Member
4 Points
12 Posts
uploading files amazon s3
Feb 19, 2012 08:12 PM|LINK
Hi,
I have a problem in uploading files to an amazon s3 account.
I found the follow link
http://www.codeproject.com/Articles/186132/Beginning-with-Amazon-S3
and I solved my problem (the part of uploading) but I have the following problem:
I made a web form with an FileUpload control and a button, which when will be clicked it runs at the server side the following code
protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string path = Path.GetFullPath(FileUpload1.PostedFile.FileName);
string s3key = FileUpload1.FileName;
PutObjectRequest request = new PutObjectRequest();
request.WithBucketName(".....");
request.WithKey(s3key);
request.WithFilePath(path);
s3.PutObject(request);
}
}
My main problem is that I can't get the full path of the file, that I want to upload. Despite, I have used the below method:
Path.GetFullPath(FileUpload1.PostedFile.FileName)
I can't get the full path of the file. When I hardcode the full path, it uploads the file!
Having searching a lot, I found that there are two conflicting options for that problem.
The first is that this is impossible. For security reasons, you cannot get the full path.
The Second is that is possible using some javascript code, but I tried and I didn't figured it out.
Thank's a lot for any help in advance.
Hua-Jun Li -...
All-Star
75950 Points
5608 Posts
Re: uploading files amazon s3
Feb 21, 2012 02:45 AM|LINK
Hi Christos83,
FileUpload1.PostedFile.FileName.
This actually gives you path of the uploaded file.
But in all the newer browsers (FF 3.6 series, Chrome, IE7+) this feature has been disabled due to security reasons. Any website should not need path of a file stored in client's systems because that gives the directory structure and may expose other important things to website owner.
So in your case, the above code returned only the file name.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework