Jump to content

[SOLVED] Upload Trouble


refiking

Recommended Posts

What is wrong with this?  I can't find anything wrong.  Is it the code?  I CHMOD the file form.php and the folder upload to 755 just to make sure.  Here is the code:

 

if ( move_uploaded_file ($_FILES['uploaded'] ['tmp_name'], 'upload/' . $_FILES['name'])){
   Echo 'Successful';
   }
   else{
   Echo 'Not Successful';
   }

 

 

Link to comment
https://forums.phpfreaks.com/topic/132675-solved-upload-trouble/
Share on other sites

if ( move_uploaded_file ($_FILES['uploaded'] ['tmp_name'], 'upload/' . $_FILES['name'])){
   Echo 'Successful';
   }
   else{
   Echo 'Not Successful';
   }

 

You know its probably such a tiny thing but if you look here: $_FILES['uploaded']:o['tmp_name'], you will notice a space.... try:

if ( move_uploaded_file ($_FILES['uploaded']['tmp_name'], 'upload/' . $_FILES['name'])){
   Echo 'Successful';
   }
   else{
   Echo 'Not Successful';
   }

;D

PHP Can be a  :-X like that at times

can you post the code..

 

or try chmod 777

 

IF ($change == "yes"){
        IF ($addy == ""){
     $error = 5;
     }
     IF ($city == ""){
     $error = 6;
     }
     IF ($state == ""){
     $error = 7;
     }
     IF ($email == ""){
     $error = 9;
     }
     IF ($zip == ""){
     $error = 8;
     }
     IF ($phone == ""){
     $error = 10;
     }
     IF ($oha == ""){
     $error = 11;
     }
     IF ($ohcsz == ""){
     $error = 12;
     }
     IF ($oht == ""){
     $error = 13;
     }
     IF ($cname == ""){
     $error = 1;
     }
     IF ($lname == ""){
     $error = 3;
     }
     IF ($fname == ""){
     $error = 2;
     }
     IF ($error != ""){
     header("Location: orderform.php?id=" . $error);
     exit;
     }
   if ( move_uploaded_file ($_FILES['uploaded']['tmp_name'], 'upload/' . $_FILES['name'])){
   Echo 'Successful';
   }
   else{
   Echo 'Not Successful';
   }
}

Add the following immediately after your first opening <?php tag -

ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "<pre>";
echo "FILES:";
print_r($_FILES);
echo "</pre>";

 

Here's what it returned:

 

FILES:Array
(
)


Notice: Undefined variable: error in /hermes/web09/b2460/as.tcc08/public_html/orderform.php on line 45

Notice: Undefined index: uploaded in /hermes/web09/b2460/as.tcc08/public_html/orderform.php on line 50

Notice: Undefined index: name in /hermes/web09/b2460/as.tcc08/public_html/orderform.php on line 50
Not Successful

An empty $_FILES array either means you form is invalid, uploads are not enabled on your server, or the size of the data from the form exceeds the post_max_size setting.

 

Post your form to get help with the first possibility. Use a phpinfo() statement to check the settings for the second and third possibilities.

Here's The Form:

 

<form action="orderform.php" method="post"><input type="hidden" name="change" value="yes"><table width="100%">
<tr><td width="20%" align="left">First Name:</td><td width="25%" align="left"><input type="text" name="fname"></td></tr>
<tr><td width="20%" align="left">Last Name:</td><td width="25%" align="left"><input type="text" name="lname"></td></tr>
<tr><td width="20%" align="left">Company Name:</td><td width="25%" align="left"><input type="text" name="cname"></td></tr>
<tr><td width="20%" align="left">Email Address:</td><td width="25%" align="left"><input type="text" name="email"></td></tr>
<tr><td width="20%" align="left">Address:</td><td width="25%" align="left"><input type="text" name="addy"></td></tr>
<tr><td width="20%" align="left">City:</td><td width="25%" align="left"><input type="text" name="city"></td></tr>
<tr><td width="20%" align="left">State:</td><td width="25%" align="left"><input type="text" name="state"></td></tr>
<tr><td width="20%" align="left">Zip Code:</td><td width="25%" align="left"><input type="text" name="zip"></td></tr>
<tr><td width="20%" align="left">Telephone:</td><td width="25%" align="left"><input type="text" name="phone"></td></tr>
<tr><td width="20%" align="left">Fax:</td><td valign="top" align="left"><input type="text" name="fax"></td></tr>
<tr><td width="20%" align="left">Open House Address:</td><td valign="top" align="left"><input type="text" name="oha"></td></tr>
<tr><td width="20%" align="left">Open House City/State/Zip:</td><td valign="top" align="left"><input type="text" name="ohcsz"></td></tr>
<tr><td width="20%" align="left">Open House Time:</td><td valign="top" align="left"><input type="text" name="oht"></td></tr>
<tr><td valign="top">Special Instructions: </td><td><textarea name="si" rows="5" cols="25"></textarea></td></tr>
</table>
<hr width="80% align="center">
<table>
<tr><td width="20%" align="left">Color Copy:</td><td valign="top" align="left">Yes <input type="radio" name="cc" value="Yes">   No<input type="radio" name="cc" value="No"></td></tr>
<tr><td width="20%" valign="top" align="left">Copy Instructions:</td><td valign="top" align="left"><textarea name="ci" rows="5" cols="25"></textarea></td></tr>
<tr><td width="20%" align="left">Upload File:</td><td valign="top" align="left"><input name="uploaded" type="file"></td></tr>
<tr><td> </td><td><input type="submit" value="Submit Now"></td></tr></table></form>

An upload form need a enctype="multipart/form-data" parameter. As with any programming, start by reading the upload section in the php manual to find out the requirements for what you are doing - http://us2.php.net/features.file-upload

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.