I want the full path of a selected image to be displayed once Choose File button is clicked. Any idea on how to do that?
Asked
Active
Viewed 216 times
2 Answers
0
In your $_POST
handling, use the following:
$fullpath = $_FILES["Name_Of_The_Input_Field_For_The_File"]["tmp_name"];
See Getting complete PATH of uploaded file - PHP for a similar issue.

Nick Duncan
- 829
- 6
- 17
0
Instead of doing a double POST, you can do something like this:
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function() {
readURL(this);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="form1" runat="server">
<input type='file' id="imgInp" />
<img id="blah" src="#" alt="your image" />
</form>
Remember, that just because you've selected a file to upload doesn't mean its been uploaded. The server still hasn't received the data, thus, doing this on the client side makes a little more sense from what i gather you want to do.
(stolen from: Preview an image before it is uploaded)

Javier Buzzi
- 6,296
- 36
- 50