• 0

PHP Storing original path to uploaded image


Question

Hey,

When I upload an image, or file, how would I also store the original location of the file?

Or is it even possible?

I need to store for later reference as we have several people at work uploading images, and we need to know which computer, and file they uploaded it from.

Thanks for any help :)

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

ermmm i have not done it before BUT i would try uploading the form data to a SQL database or a varible before you continue to upload the file just treat it as a normal text input (still remember it is not) then pass the information on to the next bit of the chain ... sorry if im bad at explaining things sorry if this is no help at all

Link to comment
Share on other sites

  • 0

It's a file, so when I call $_POST I don't get anything returned...And when calling the name, it just returns the file name, not the path...

And when I print the array, it doesn't return the path either...

Link to comment
Share on other sites

  • 0

It's a file, so when I call $_POST I don't get anything returned...And when calling the name, it just returns the file name, not the path...

And when I print the array, it doesn't return the path either...

ah ok try this in your code $_FILES['uploadedfile']['name'] not sure if it will work but should return the original directory when uploading (get it to echo or something to test if its working) sorry if im giving you old info but i assume you are using ['file']['name']

Link to comment
Share on other sites

  • 0

ok immmm going to bed dont give up it is possible im just not sure 100% how i would normally play with code and use techniques from other parts of the php lingo and combine them to make something. just use your skills and knowledge to fiddle a bit.

Link to comment
Share on other sites

  • 0

echoing the ['file']['name'] just shows the name of the file, and not the actual path...

Thanks for your help though :) I'll just have to keep playing...

Link to comment
Share on other sites

  • 0

Or is it even possible?

It's not possible with any web browser. Would you like if websites were able to scan your local file structure? Yeah, that's why it isn't possible. If you want to access the user's system you need to use browser extension, applet or desktop application to upload the files. Possibly even JS can do it, in case of a insecure browser that doesn't secure the file upload fields. Web browsers only allow accessing the type, name and contents.

Link to comment
Share on other sites

  • 0

You could use the $_SERVER['REMOTE_ADDR'] variable to get the IP address for identifying the computers (assuming they are static IPs), but to my knowledge it is impossible to get the original location of the file on the uploading computer.

If you know who will be using it and how they will be using it (ie: they are on a local network or intranet and it isn't a public website) then you could have a single text or select field on the form for the user to choose the "computer name" they are uploading from.

Link to comment
Share on other sites

  • 0

I was afraid you guys would say that...I wasn't sure if it would be possible...Oh well...We will just have to make due without it. It was only so we could find the files faster.

I don't have time to make a browser extension...Never made one before lol And we use 3 different browsers...Opera, Chrome and Firefox lol

Oh well, thank you for the help though :)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.