Link to home
Start Free TrialLog in
Avatar of andyw27
andyw27

asked on

Problem passing $_FILES variables

Hello,

All of a sudden my upload page has stopped working.  I tried to find anything that might be broken and have found this:

Here is the upload form code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="form1.php" method="post" enctype="multipart/form-data" name="material_upload" id="material_upload_id">
<table width="450" border="0" cellpadding="2" cellspacing="2">
    <tr>
      <td width="210" class="tableHeaderText">&nbsp;</td>
      <td width="195">&nbsp;</td>
      <td width="34"><input name="hidden_upload_material" type="hidden" id="hidden_upload_material" value="upload_material" /></td>
    </tr>
    <tr>
      <td><input type="hidden" name="MAX_FILE_SIZE" value="3000000"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="tableHeaderText">Image:</td>
      <td><input name="uploaded_image" type="file" id="uploaded_image"></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td colspan="2"><div align="right">
        <input type="submit" name="cmd_upload" id="cmd_upload" value="Add Details" />
      </div></td>
      </tr>
  </table>
</form>
</body>
</html>


As you can see if points to form1.php

Here is the code for that:

(see code window)


-----------
I would expect of 4 $_FILES to be populated here however all it gathers is the filename and a value of 0 for the size.  Both tmp_name and type are blank.

Does anybody have idea what could of happened here?

Thanks.
<?php
 
// Get MySQL connection
include "./includes/SimpleImage.php";
 
 
 
///////////////////////////////////////////////////////////
 
// Upload image to server
 
$fileName = $_FILES['uploaded_image']['name'];
$tmpName  = $_FILES['uploaded_image']['tmp_name'];
$fileSize = $_FILES['uploaded_image']['size'];
$fileType = $_FILES['uploaded_image']['type'];
 
?>
<table width="50%" border="1" align="center">
  <tr>
    <td width="54%">File Name</td>
    <td width="46%"><?php echo $fileName; ?></td>
  </tr>
  <tr>
    <td>Tmp Name</td>
    <td><?php echo $tmpName; ?></td>
  </tr>
  <tr>
    <td>File Size</td>
    <td><?php echo $fileSize; ?></td>
  </tr>
  <tr>
    <td>File Type</td>
    <td><?php echo $fileType; ?></td>
  </tr>
</table>

Open in new window

Avatar of WB-Internal
WB-Internal
Flag of United States of America image

is it exceeding the max sizes? Either upload or buffer or whatever other size contraints are setup?

prob need to review phpinfo() to check them all.

do you have error reporting on so you can see any errors?

Did you recently upgrade your PHP?

Is your upload_tmp_dir setup in the ini? and permissions to that location setup correctly?
  - try touch() and then unlink() (read up on them to determine what they do) against a dummy file in your upload_tmp_dir. that should offer a good permission test.

also, who knows maybe something up in your include() file, maybe you should comment it out to verify.
Also, it is completely stupid, but try print_r($_POST) & print_r($_FILES) just to get a clear picture of the raw data posted. (should be the same as populating / echoing out your variablesas you did in the script above but might as well.
doh, missed the subject in the first sentence:
it refers to -> the file you're uploading
ASKER CERTIFIED SOLUTION
Avatar of andyw27
andyw27

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is the file you're trying to upload intact and not corrupt?
user error is not a stability issue.