Jump to content

Get Filepath from file input type.


aNubies

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/275893-get-filepath-from-file-input-type/
Share on other sites

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

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 :happy-04: .

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.