problems passing files from a form

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 17
Joined: Wed Jul 03, 2002 3:10 am

Wed Feb 26, 2003 6:52 am

I am trying to pass a file from a form to another php page that will upload it.

Each time the variable passed end up being null.

The settings in my form are:

<form name="form1" method="post" action="upload.php" enctype="multipart/form-data">
<input type="file" name="pageimage">
<input type="submit" name="Submit" value="Submit">

The form works fine, I can browse to a file on my local machine and its filename/path are added in the text box.

But when I check the value of the variable $pageimage on the "upload.php" page it is NULL.

I am checking it thus:

$pageimage = $HTTP_POST_VARS['pageimage'];
echo "Image type is = ".gettype($pageimage);

Does anyone know why it may not be passing the value across?


Oleg Butuzov
Last Samuray
Last Samuray
Posts: 824
Joined: Sun Jun 02, 2002 3:09 am

Wed Feb 26, 2003 7:35 am



User avatar
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Wed Feb 26, 2003 11:22 am

sametch wrote:$pageimage = $HTTP_POST_VARS['pageimage'];
echo "Image type is = ".gettype($pageimage);

inorder to get the type you can use

Code: Select all

echo $_FILES['pageimage']['type'];

This will echo the mime type of the file.

Post Reply