Jump to content

How to find full path of a file upload field in a form ? $_FILES['file1'] ...


Recommended Posts

I need a way to find the full path of a file uploaded by file upload form box.

 

$_FILES['file1']['name'] gives just file name.

 

I have a file upload form and if the user submitted something wrong I want the page to go back and have the forms maintain its values (the full path to local file, e.g: "c:/docs/landscape.jpg").

 

Any way to do that? This is a more complex applications so using another upload tool is not an option.

 

Any ideas?

Thanks.

 

- Adrian.

Well it depends on what you mean.  You can database the name of the file, for example the path.  Use document root server variable to help track part of it, the rest is normally custom anyway.

If you are wanting to set it in the form, add another field for the path and make it a hidden form field, it's an easy way to track what form it's coming from.

If you meant something else, please re-specify.

Thanks for the replies.

So I understand the best way is to create another hidden form field and to copy the value from file field to this hidden field.

Will this work? Anyone knows how the JavaScript for this should look?

After I duplicated the "full path" of file upload fields so I can access it, I found that you cannot set a default path to file (in file upload fields) so I will have to drop the idea.

As I said I wanted to set the default value in that form if user previously submitted an upload form but he was sent back.

Thats basically what I said... a default value cannot be set.... what was suggested is to use a hidden form field to keep this information, but it really don't help as the user will still have to navigate to the file again anyway.

 

Nate

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.