allaboutthekick Posted November 7, 2006 Share Posted November 7, 2006 I found a script on the internet and edited it a lot but i dont think i compiled it completely correctly, please review and help me fix my mistakes.1. It wont delete images that are too big from the server and wont display the error2. Only jpeg images are allowed but when other image types are uploaded it just causes a warning.[code]<?phpif (isset($_COOKIE['User'])) { $user = $_COOKIE['User']; setcookie('User',$user,time()+(60*60));} else { Echo 'Please login before posting an image'; die();}$Message="";$msg="";$file_upload="false";if ($_FILES['userfile']['tmp_name']) {$userfile=$_FILES['userfile']['tmp_name'];$userfile_size=$_FILES['userfile']['size'];$userfile_type=$_FILES['userfile']['type'];$userfile_name=$_FILES['userfile']['name'];$file_upload="true";if ($userfile_size > 500000){$Message=$Message."Your uploaded file size is more than 500KB so please reduce the file size and then upload.<BR/>" ;$file_upload="false";}if (!$userfile_type =="image/jpeg"){$Message=$Message."Your uploaded file must be of JPG. Other file types are not allowed<BR/>";$file_upload="false";} $badd = time();$baseadd = $badd . ".jpg"; //User time stamp$add="imgs/o".$baseadd; if ($file_upload='true') { if(move_uploaded_file ($userfile, $add)){ $msg = $userfile_name . " Has been uploaded"; }else{echo "Failed to upload file Contact Site admin to fix the problem";}$out_file = "imgs/". $baseadd;$max_width = 300;$max_height = 300;list($width_orig, $height_orig) = getimagesize($add);if ($max_width && ($width_orig < $height_orig)) { $max_width = ($max_height / $height_orig) * $width_orig;} else { $max_height = ($max_width / $width_orig) * 1;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26507-script-review/ Share on other sites More sharing options...
HuggieBear Posted November 9, 2006 Share Posted November 9, 2006 You need to change this... [code=php:0]if ($file_upload='true')[/code] to this... [code=php:0]if ($file_upload == "true")[/code] Notice the double equals sign!RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/26507-script-review/#findComment-122082 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.