Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Get Filepath from file input type.

$
0
0

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.


Viewing all articles
Browse latest Browse all 13200

Trending Articles