I want to create a "browse" button that will upload the NAME of a file (just the name, NOT the file) and pass that name onto another page. I have written the following:

echo '<FORM ENCTYPE="multipart/form-data" ACTION="InsertImageFile.php" METHOD=POST>';

 echo '<table cellpadding = 5 border = 1> <tr><td>';
 echo 'File Name </td><td>';
 echo '<INPUT NAME="FileName" size ="45" TYPE="file">';
 
 echo '</td></tr> <tr><td>';

 echo 'Description </td><td> <input type = "text" name = "PicDescrip" size ="45" value = "">';
  echo '</td></tr> <tr><td>';

 echo '<input type = "submit" value = "Add Image"> </td></tr></table></center></form>';

When this code executes nothing is sent to the receiving page. Am I right is guessing that the system is trying to send the file instead of the text of the file name?

How do I fix this?

I havent tested this, but you can create a hidden form field, and set its value to the filename upon selecting with javascript. When the form submits, try deleting the file input beforehand from the DOM.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.