0

I'm using wampserver on my computer and wrote a simple html-form:

 <form name="test" action="upload_file.php" method="post"> <label for="file">Filename:</label> <input type="file" name="picurl" id="file" ><br> <input type="submit" name="submit" value="Submit" > </form> 

When I click on "browse" and open a file ,for example pil.png it shows in the input textarea the full path(C:\Users\hope\Desktop\images\pil.png) I want this exact link saved but when I try to catch it $name = $_POST["name"];it only displays this- "pil.png" not the full path. why?

3
  • What would you be doing with the full path on the server to begin with? Commented Dec 7, 2012 at 8:56
  • o.k good question, I just want to arrange all the images in my computer that i need for a certain project while practicing html css php etc…. Commented Dec 7, 2012 at 9:23
  • thank you all, i guess i will try different approach. Commented Dec 7, 2012 at 10:16

4 Answers 4

4

You cannot get the complete local file path. Only the file data itself and its name is submitted to the server. The file path being displayed in the input element is only visual styling, it has no functionality.

File elements are very limited for security reasons, and that's a good thing.

Sign up to request clarification or add additional context in comments.

2 Comments

security reasons even if the images and the wampserver are on the same comuter?
Browser security is browser security. There are no exceptions.
1

The browser doesn't submit the full path because it would be a privacy problem, you would be exposing your file system structure to the server. It's not relevant to the server and the server doesn't need to know where the file was located on the client's filesystem.

Comments

-2

You are getting only file_name because you are not asking for path.

to get full path you have to use

public string SplFileInfo::getRealPath ( void ) 

Comments

-2

try

var_dump($_FILES['picurl']); 

1 Comment

var _dump is same as? echo "<pre>"; print_r($picurl); echo "</pre>";

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.