Jump to content

[SOLVED] Problem with upload form. Please help!


patheticsam

Recommended Posts

Hi! I have a problem with a php upload script. It's really weird cause when I test it with one hoster (runhosting.com) it works perfectly and when I try it on another hoster (that I just signed up with) I can't seem to get the picture uploaded. The hoster i'm with runs under unix with PHP 5 activated. I 've set the upload folder permissions to 777 and still dosen't works.....

 

 

Here's the upload script I have (upload.php) :

 

 

<?php

if ($userfile_size >250000){$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload. Visit the help page to know how to reduce the file size.<BR>";
$file_upload="false";}

if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";}

$add="pictures/$userfile_name";

if(move_uploaded_file ($userfile, $add)){
echo "<center>File successfully uploaded</center>";
}else{echo "Failed to upload file Contact Site admin to fix the problem";}

?>

 

 

and here's my form (form.html) :

 

<FORM ENCTYPE="multipart/form-data" ACTION="upload.php" METHOD=POST name=upload>
<br><br>
<table border=0 cellpadding=0 cellspacing=0 width=425 align=center>
<tr>
<td width=250 height=35><b>Name :</b></td>
<td align=right><input type="text" name="email" size=43 class="texta"></td>
</tr>
<tr>
<td width=250 height=35 bgcolor="D8D8D8"><b>Phone number :</b></td>
<td align=right bgcolor="D8D8D8"><input type="text" name="phone" size=43 class="texta"></td>
</tr>
<tr>
<td width=250  height=35><b>Picture</b></td>
<td align=right><input NAME="userfile" TYPE="file" class="texta" size=29> </td>
</tr>
<tr><td colspan=2 align=right><br><br><b>2 / 2 </b><input name=submit type="submit" value="Submit ad"></td></tr>
<tr>
</table>
</form>

 

 

If anyone can help with this issue it would be greatly appreciated!

 

Thank you

I have error_reporting(E_ALL); at the very top of the script but I don't get any error. The only thing I have is the "Failed to upload file Contact Site admin to fix the problem" returned by the If/else statement.....Just I as I said I just can't undertant why this script works at runhosting and not at my new hoster....(?)

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.