Page 1 of 1

another thread about file uploading.......

Posted: Mon Mar 01, 2004 2:48 pm
by dull1554
i have written a image upload script for a image gallery that i designed, and it works fine when i try to upload a .....say 200kb file, but around 6-700kb it gives me the max execution time error. but i know that is not a filesize problem cause i can upload a 2.00mb file on the same server.

heres the code....

Code: Select all

if(!isset($_POST['submit'])){
Print <<< EOT
<form enctype="multipart/form-data" method="POST" action="index.php?l=admin_qwertylx.php&admin=newimg">
Image: <input type="file" name="userfile" size="33"><br>
Info: &nbsp;<textarea cols=36 rows=10 name=info></textarea><br>
Choose gallery: <select name=cat>
EOT;
$query = mysql_query("SELECT * FROM cat");
while($array = mysql_fetch_array($query))
{
Print <<< EOT
<option value={$array['name']}>{$array['name']}</option>
EOT;
}
Print <<< EOT
</select><br>
<input type="submit" value="Submit" name="submit">
</form>
EOT;
}
else{
$cat = $_POST['cat'];
$info = $_POST['info'];
$filename = eregi_replace(" ","%20",$_FILES["userfile"]["name"]);
$stripspaces = eregi_replace("_"," ",$_FILES["userfile"]["tmp_name"]);
$name=str_replace(chr(32),chr(95),$_FILES['file']['name']);
if (is_uploaded_file($stripspaces)) {

copy($_FILES["userfile"]["tmp_name"], "gal/" . $_FILES["userfile"]["name"]);

echo "<p>File uploaded successfully.</p>";

}

$sql = mysql_query("INSERT INTO images (cat, info, src) VALUES('$cat', '$info', '$filename')");
if($sql){
    echo "Image added";
}
elseif(!$sql){
    echo "Problem......Image not added";
}
else{
    echo "Problem executing the script!";
}

}
any thoughts as too why this is hapening????

THANX dull

Posted: Mon Mar 01, 2004 2:50 pm
by markl999
The script maybe just exceeding the default execution time of 30seconds. Try using http://php.net/set_time_limit
Eg, set_time_limit(0);

Posted: Mon Mar 01, 2004 2:53 pm
by dull1554
so it can just crap out just because it exceeds the time limit, but it takes a hole heck of alot longer then 30 seconds to get that error, sometimes minutesbut ill try it out.....thanx

Posted: Tue Mar 02, 2004 3:20 pm
by dull1554
well i tried to use set_time_limit() but to no avail, it did not work

Posted: Tue Mar 02, 2004 4:00 pm
by markl999
Is there anything unique about a file(s) that won't upload? ie file name or type as compared to those that upload ok?

Posted: Tue Mar 02, 2004 4:21 pm
by infolock
try putting this in there and see if it helps any...

<INPUT type=hidden value=2000000 name=MAX_FILE_SIZE><input type="file" name="userfile" size="33">