NSW42 Posted March 28, 2007 Share Posted March 28, 2007 Heya again to anyone that may know where ive gone wrong, for some reason now the script wont allow any pic gif jpeg to upload, if anyone can picked to see whats wrong would be appreciated.. <?php include("config.php"); include("user_check.php"); $sql = mysql_query("SELECT * FROM users WHERE username = '$_COOKIE[username]'"); $row = mysql_fetch_array($sql); $path = "propics/"; $file_size_max = 30024 * 50024; $possible_size = round($file_size_max / 50024); $possible_extensions = array ('jpg', 'jpeg', 'pjpg', 'gif', 'bmp', 'png'); $count_possible_extensions = count($possible_extensions); if (!$case) $case = 1; switch ($case) { case 1: ?> </div><form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <table border="0" cellspacing="0" cellpadding="4"> <tr> <td> <B><font face='Tahoma' size='2' color='ffffcc'> SELECT A PICTURE FROM YOUR COMPUTER<br>TO ADD TO YOUR PROFILE.Jpg,Gif,Bmp ONLY.<br>200x200 or About 70kb max size<br>Your old picture will be deleted<br>Please make sure your picture is square <? echo $lang; ?> <br> <font face='Tahoma' size='2' color='#003366'><? echo $lang; ?> <br> <br> <input type="file" name="plaatje" size="40"> <br> <input type="hidden" name="case" value="2"> <input type="submit" value="<? echo UPLOAD; ?>"> <br> </td> </tr> </table> </form> <?php break; case 2: if(!$_FILES[plaatje]) { echo 'You didn\'t select an picture.'; } if($_FILES[plaatje]) { $file_size = round($_FILES[plaatje] / 50024); $file_type = $_FILES[plaatje][type]; $file = basename($_FILES[plaatje][name]); $ext = explode(".", $file); $file_extension = $ext[1]; $file_name = $ext[0]; $fileinfo = pathinfo($plaatje); if(!in_array($fileinfo['extension'],$possible_extensions)) exit('File not allowed. Only gif, jpeg, bmp allowed.'); if(filesize($plaatje) > 85000) exit('File too big. Max size 80kb.'); if($file_size > $possible_size) echo "</div>$lang kb"; if (!in_array(strtolower($file_extension),$possible_extensions)) { echo "</div>$lang "; for ($i = 0; $i < $count_possible_extensions; $i++ ) echo "</div>"; } else { $file_name = "artikel_pic"; $n = 0; $temp_name = $file_name; // while (file_exists($path . $temp_name . $n . "." . $file_extension)) $n = $n + 1; unlink($path.$file_name.'.'.$file_extension); if(move_uploaded_file($plaatje, $path . $file_name . "." . $file_extension)) { $update1 = mysql_query("UPDATE users SET pro_pic = '$baseurl$path$file_name.$file_extension' WHERE username = '$_COOKIE[username]'") or die(mysql_error()); print("Photo uploaded"); exit; } else { echo "</div>"; } } } break; } ?> Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/ Share on other sites More sharing options...
NSW42 Posted March 29, 2007 Author Share Posted March 29, 2007 any ideas at all on this :-\ Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-217340 Share on other sites More sharing options...
DeathStar Posted March 29, 2007 Share Posted March 29, 2007 here's one! [ code ][ /code ] Please. And you can get an uploading script on google! Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-217344 Share on other sites More sharing options...
NSW42 Posted March 29, 2007 Author Share Posted March 29, 2007 thanks but mine did work until i did some extra things to it, but now it says only jpeg gis etc allowed even thou it is :-\ but i cant see where ive gone wrong :-X Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-217349 Share on other sites More sharing options...
DeathStar Posted March 29, 2007 Share Posted March 29, 2007 look at this line: $possible_extensions = array ('jpg', 'jpeg', 'pjpg', 'gif', 'bmp', 'png'); try it like this: $possible_extensions = array ('.jpg', '.jpeg', '.pjpg', '.gif', '.bmp', '.png'); Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-217353 Share on other sites More sharing options...
NSW42 Posted March 29, 2007 Author Share Posted March 29, 2007 same result 'File not allowed. Only gif, jpeg, bmp allowed. :'( Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-217366 Share on other sites More sharing options...
NSW42 Posted March 29, 2007 Author Share Posted March 29, 2007 anyone got anymore ideas on this, im lost bigtime :'( Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-217815 Share on other sites More sharing options...
NSW42 Posted March 30, 2007 Author Share Posted March 30, 2007 Will give it one last post before killing it, HELP!!!!!!!!!!! :'( Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-218431 Share on other sites More sharing options...
NSW42 Posted April 1, 2007 Author Share Posted April 1, 2007 Will give it one last post before killing it, HELP!!!!!!!!!!! :'( ok one more try anyone Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-218958 Share on other sites More sharing options...
NSW42 Posted April 2, 2007 Author Share Posted April 2, 2007 hey again, the whole script had to be redone, but thanks to anyone who may had a shot or look at it...will close it as solved Link to comment https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/#findComment-219654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.