aNubies Posted March 20, 2013 Share Posted March 20, 2013 Hello guys, I'm trying to get the full filepath that was browsed in input file type. I've search a lot in google and gave me basename, $_Files but can't make it work. Can you show me how to get it in the input file type and then display it in a another textbox, thank you in advance. This is my trial. <form action="" method="POST"> <input type="file" name="fileupload" /> <input type="text" name="filepath" /> <input type="submit" value="upload file" /> </form> /* This php code doesn't work at all */ <?php $_POST['filepath'] = $_FILES['fileupload']; $_POST['filepath'] = basename($_FILES['fileupload']['name']; ?> /* This only display the name of the file that uploaded. */ <?php echo $_POST['fileupload']; ?> So as I have said what I want to achieve is that when I browse the file either after I press the upload file button it will display the full path in a another textbox or after I browse the file it will display in another textbox right away. Quote Link to comment https://forums.phpfreaks.com/topic/275893-get-filepath-from-file-input-type/ Share on other sites More sharing options...
aNubies Posted March 20, 2013 Author Share Posted March 20, 2013 Anyone can help me, and I forget to tell why I need this because basically I'm going to create a copy of the file but re-scale and reduced quality. I made to do the re-scaling and reduce quality its just that I need the full path that is on the file input type. Thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/275893-get-filepath-from-file-input-type/#findComment-1419731 Share on other sites More sharing options...
Solution monkeypaw201 Posted March 20, 2013 Solution Share Posted March 20, 2013 (edited) Hi aNubies, I don't believe this is possible in PHP, only in Javascript. Check out this similar thread: http://forums.phpfreaks.com/topic/66876-how-to-find-full-path-of-a-file-upload-field-in-a-form-filesfile1/ Edited March 20, 2013 by monkeypaw201 Quote Link to comment https://forums.phpfreaks.com/topic/275893-get-filepath-from-file-input-type/#findComment-1419740 Share on other sites More sharing options...
P5system Posted March 20, 2013 Share Posted March 20, 2013 You can create a Image upload function and an Image thumb creation function and call this thumb creation function in Image Upload function. Then there is no need of file path Quote Link to comment https://forums.phpfreaks.com/topic/275893-get-filepath-from-file-input-type/#findComment-1419744 Share on other sites More sharing options...
aNubies Posted March 20, 2013 Author Share Posted March 20, 2013 Thank you very much for all the responses, as further research with Mr. Google yeah it is not possible to get the value of file input due to security issues. By occurances I accidentally used the $_FILES['']['tmp_name'] and it does what I need. Thank you very much guys . Quote Link to comment https://forums.phpfreaks.com/topic/275893-get-filepath-from-file-input-type/#findComment-1419746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.