Avatar of andyw27
andyw27 asked on

Problem passing $_FILES variables


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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<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">
      <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>
      <td><input type="hidden" name="MAX_FILE_SIZE" value="3000000"></td>
      <td class="tableHeaderText">Image:</td>
      <td><input name="uploaded_image" type="file" id="uploaded_image"></td>
      <td colspan="2"><div align="right">
        <input type="submit" name="cmd_upload" id="cmd_upload" value="Add Details" />

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?

// 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">
    <td width="54%">File Name</td>
    <td width="46%"><?php echo $fileName; ?></td>
    <td>Tmp Name</td>
    <td><?php echo $tmpName; ?></td>
    <td>File Size</td>
    <td><?php echo $fileSize; ?></td>
    <td>File Type</td>
    <td><?php echo $fileType; ?></td>

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon

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

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Ray Paseur

Is the file you're trying to upload intact and not corrupt?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

user error is not a stability issue.