Jump to content

Get Filepath from file input type.


aNubies
Go to solution Solved by monkeypaw201,

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
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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.