Reputation: 1
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?
Upvotes: 0
Views: 93
Reputation: 2390
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 )
Upvotes: -2
Reputation: 522513
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.
Upvotes: 4
Reputation: 64536
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.
Upvotes: 1