1

I wrote some code to upload files to amazon S3, if I put a full file path manually It successfully uploads the file from my computer. What I'm trying to do is use a file upload control and store the full path in a variable so that I can use it for my amazon method. Ive read everywhere it seems that the browser won't let you get the full file path for security reasons.

How can I get the full file path? Should I just store the files on my webserver and point my amazon method to the server path, and then use the file upload control to tell it what the filename is? I wish I could just do a straight shot to amazon...

7
  • you can never get the path from the clients browser... but i fail to see how that can be in ANY way relevant. You get the filename, so just construct the full path your self. Ie. put all uploaded files in one predefined folder. Commented Dec 20, 2010 at 6:21
  • @Andrew Barber, Apology accepted. Commented Dec 20, 2010 at 6:25
  • @Pauli, I was trying to not save the file to my webserver then construct the absolute path. I was trying to take it straight from the client to amazon. Unfortunately, the amazon api asks for a abs path. I guess I will have to save the file to my webserver. No big deal I guess. Commented Dec 20, 2010 at 6:27
  • why would you need to save it on the webserver!? if its because the amazon api requires a file path to read from when uploading im sure there is an overload taking a stream as well! Commented Dec 20, 2010 at 6:28
  • @Pauli, The SDK for this is not good, they show you how to create objects(files with nothing in them, which there is no real world reason why you would want to do this),but not how to upload a real file, I had to poke around and figure it out on my own to get as far as I have already. Commented Dec 20, 2010 at 6:54

3 Answers 3

1

First we have to save the file path and then we take it from

string filepath=Path.GetFullPath(UploadFile1.FileName.toString());
Sign up to request clarification or add additional context in comments.

Comments

0

I came across this link which has a great tutorial and even gives you a working sample project. (this is different from the code that the .net SDK includes...) http://aws.amazon.com/articles/774?_encoding=UTF8&jiveRedirect=1

Comments

0

We can't take full path in HTML or JS as it violets security so whenever you try to see the path it shows fakepath

so to resolve this issue you can make a seprate folder and you can store the uploaded file there and in the code you can take that folders path as default and use it as a absolute path.

You can get the full path using Python Tkinter but it is limited for desktop app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.