darknessmdk Posted January 31, 2007 Share Posted January 31, 2007 I've been working on a multiple file upload form for a few days now and finally got it working. However when I tried to set a file size limit it throws me errors.[code] <? if(isset($HTTP_POST_VARS['Upload'])) { $discription = 'N/A'; $price = 'N/A'; $caption = 'N/A'; $uploaddir = "photography"; // ============== // Upload Part // ============== //This is our size condition if ($file_size > 1000000){ echo "Your file is too large"; } else { foreach ($_FILES["photofile"]["error"] as $key => $error) { if($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photofile"]["tmp_name"][$key]; $name = $_FILES["photofile"]["name"][$key]; move_uploaded_file($tmp_name, "$uploaddir/$name"); $photo = "$uploaddir/$name"; $checked = $_POST['type2']; foreach ($checked as $type) { include("database.php"); $id = $_SESSION['id']; $result = mysql_query("INSERT into valphoto(photo, caption, type, price, discription, id) VALUES('$photo', '$caption', '$type', '$price', '$discription', $id)"); }}} if($result == TRUE) { echo "Your Photos have been uploaded!"; } else { echo "There was a problem uploading, Try again"; } mysql_close($linkID); } } ?>[/code]Something about the mysql_close($linkID); not being is not a valid connection? Any help would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/ Share on other sites More sharing options...
fert Posted January 31, 2007 Share Posted January 31, 2007 you don't need to close mysql connections usually because of php's garbage collection Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-173368 Share on other sites More sharing options...
Hypnos Posted January 31, 2007 Share Posted January 31, 2007 As the above poster said, you don't absolutely have to tell the connections to close. They will automaticly after the script is done.But, the reason this is failing is probably because that var isn't the one set in your database.php file.Look at example 1 here:http://us2.php.net/mysql_close Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-173376 Share on other sites More sharing options...
darknessmdk Posted January 31, 2007 Author Share Posted January 31, 2007 i didn't know that. but The database file works in everywhere else that i use it though. Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-173621 Share on other sites More sharing options...
darknessmdk Posted January 31, 2007 Author Share Posted January 31, 2007 I took out mysql_close($linkID); and now it rejects every file i upload. if their over my size limit and under. Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-173626 Share on other sites More sharing options...
darknessmdk Posted February 1, 2007 Author Share Posted February 1, 2007 any know whats wrong? Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-174156 Share on other sites More sharing options...
HuggieBear Posted February 1, 2007 Share Posted February 1, 2007 Quick question... Where are you defining $file_size?You are using variable that doesn't exist in an if condition...[code]<?phpif ($file_size > 1000000){ echo "Your file is too large";}?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-174478 Share on other sites More sharing options...
darknessmdk Posted February 1, 2007 Author Share Posted February 1, 2007 [code]<?phpif ($photofile_size > 1000000){ echo "Your file is too large";}?>[/code]it whats its suppost to be, whe i copied the code over to this i must of forgot to change it, Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-174666 Share on other sites More sharing options...
Hypnos Posted February 1, 2007 Share Posted February 1, 2007 [quote author=darknessmdk link=topic=124815.msg517976#msg517976 date=1170252801]I took out mysql_close($linkID); and now it rejects every file i upload. if their over my size limit and under.[/quote]What's the error? Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-174747 Share on other sites More sharing options...
darknessmdk Posted February 4, 2007 Author Share Posted February 4, 2007 it still says my file is too large, no matter what size i upload. Quote Link to comment https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/#findComment-176563 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.