Jump to content

Getting value from <INPUT TYPE="file"


RogerInHawaii

Recommended Posts

I have a simple form on my page as follows:

 

<form METHOD=post ENCTYPE="multipart/form-data">
   <input TYPE="file" NAME="filename">
   .. other input fields...
</form>

 

which produces a text control plus a Browse button which allows the user to either directly enter a file name or select a file by bringing up a browse dialog.

 

After the user subsequently hits the Submit button for the form, in the processing of the form data I attempt to retrieve the file name that he has entered, with the following:

 

<?php
$TheFileName = $_POST['filename'];
?>

 

but no matter what the user enters the retrieved file name is always empty. I can always get the value in other form fields, but never the one in the File field.

 

What am I doing wrong?

Link to comment
Share on other sites

I'm assuming you're trying to upload files?  If so, Google PHP uploads or something like that.

 

The files are stored in the $_FILES array, and each key of that array breaks down a little further to offer information about the files and what not ;p.

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.