garydt Posted August 20, 2007 Author Share Posted August 20, 2007 Sorry if i sound stupid but what do you mean by 'opening' images? I thought it meant putting them up on the screen. Yes, post your code please. Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-328794 Share on other sites More sharing options...
phpknight Posted August 20, 2007 Share Posted August 20, 2007 To show the image on the screen, I just save it to a file and then do an img src tag. What do you do? Let me know. Actually, post your entire code as well because I want to try that on my server first. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-328851 Share on other sites More sharing options...
garydt Posted August 20, 2007 Author Share Posted August 20, 2007 I uploaded a big file(10mb) via FTP and then tried to open it through img src - <img src="<?php print $pic1; ?>" border="0" /> Anyway, here's my entire code where i upload, save, and resize the image to 2 different sizes and save to 2 different folders. <?php require_once('Connections/elvisdb.php'); ?> <?php session_start(); error_reporting(E_ALL); if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $logon = ($_SESSION['MM_Username']); $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags "'([\r\n])[\s]+'", // Strip out white space "'&(quot|#34);'i", // Replace html entities "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\d+);'e", "'www.'", "'ww.'", "'bollocks'","'Bollocks'","'bugger'","'bullshit'","'cunt'","'shit'","'fuck'","'fuk'","'Bollocks'","'Bollocks'","'Bugger'","'Bullshit'","'Cunt'","'Shit'","'Fuck'","'Fuk'","'Fuck'","'FUCK'","'BOLLOCKS'","'CUNT'","'SHIT'","'BUGGER'","'WANK'","'Wank'","'cock'","'COCK'","'tits'","'TITS'","'fanny'","'FANNY'","'SLUT'","'WHORE'","'BITCH'","'slut'","'whore'","'bitch'","'bastards'","'barstards'","'BASTARD'","'Bastards'","'piss'","'arse'","'dick'","'pratt'","'pillock'","'shite'","'tosser'","'faggot'","'fag'","'slapper'","'ponce'","'plonker'","'knob'","'vagina'","'turd'","'prick'","'hooters'","'knockers'","'PISS'","'ARSE'","'DICK'","'PRATT'","'PILLOCK'","'SHITE'","'TOSSER'","'FAGGOT'","'FAG'","'SLAPPER'","'PONCE'","'PLONKER'","'KNOB'","'VAGINA'","'TURD'","'PRICK'","'HOOTERS'","'KNOCKERS'","'Fuck'","'Fuck'","'Bollocks'","'Cunt'","'Shit'","'Bugger'","'Wank'","'Wank'","'Cock'","'Cock'","'Tits'","'Tits'","'Fanny'","'Fanny'","'Slut'","'Whore'","'Bitch'","'Slut'","'Whore'","'Bitch'","'Bastards'","'Barstards'","'Bastard'","'Bastards'","'Piss'","'Arse'","'Dick'","'Pratt'","'Pillock'","'Shite'","'Tosser'","'Faggot'","'Fag'","'Slapper'","'Ponce'","'Plonker'","'Knob'","'Vagina'","'Turd'","'Prick'","'Hooters'","'Knockers'","'Piss'","'Arse'","'Dick'","'Pratt'","'Pillock'","'Shite'","'Tosser'","'Faggot'","'Fag'","'Slapper'","'Ponce'","'Plonker'","'Knob'","'Vagina'","'Turd'","'Prick'","'Hooters'","'Knockers'", "'Fucker'","'Fuckers'","'Motherfucker'","'fucker'","'fuckers'","'motherfucker'","'motherfuckers'","'mutherfuckers'", "'mofferfuckers'","'Fuck'","'Fuck'","'Bollocks'","'Cunt'","'Shit'","'Bugger'","'Wank'","'Wank'","'Cock'","'Cock'","'Tits'","'Tits'","'Fanny'","'Fanny'","'Slut'","'Whore'","'Bitch'","'Slut'","'Whore'","'Bitch'","'Bastards'","'Barstards'","'Bastard'","'Bastards'","'Piss'","'Arse'","'Dick'","'Pratt'","'Pillock'","'Shite'","'Tosser'","'Faggot'","'Fag'","'Slapper'","'Ponce'","'Plonker'","'Knob'","'Vagina'","'Turd'","'Prick'","'Hooters'","'Knockers'","'Piss'","'Arse'","'Dick'","'Pratt'","'Pillock'","'Shite'","'Tosser'","'Faggot'","'Fag'","'Slapper'","'Ponce'","'Plonker'","'Knob'","'Vagina'","'Turd'","'Prick'","'Hooters'","'Knockers'", "'Fucker'","'Fuckers'","'Motherfucker'", "'mufferfuckers'"); // evaluate as php $replace = array ("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)"); $editFormAction = ''; if(isset($_POST['sent'])){ unset($submit); if (isset($_POST['sent'])) $submit = true; else die('Error: No file got sent'); if($_FILES['file']['name']) { $arr = getimagesize($_FILES['file']['tmp_name']); list($width, $height, $type, $attr) = getimagesize($_FILES['file']['tmp_name']); if($type == FALSE) { header("Location: uploadform2.php"); exit(); } elseif($type != 2) { header("Location: uploadform2.php"); exit(); } } $fieldname = $_FILES['file']; function resizeimage($name){ $filename = './uploads/'.$name; if(file_exists($filename)) { ini_set('memory_limit', '500M'); set_time_limit ( 0 ); $image = imagecreatefromjpeg($filename); //unresized image $im_info = getimagesize($filename); //unresized image $im_width = $im_info[0]; $im_height = $im_info[1]; $im_flag = $im_info[2]; //max height: 140px; max width: 140px if($im_width >= $im_height) { $im_divice = $im_width / 140; }else { $im_divice = $im_height / 140; } $thumb_width = $im_width / $im_divice; $thumb_height = $im_height / $im_divice; //create empty image $thumb = imagecreatetruecolor($thumb_width, $thumb_height); //resize image imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height); if(imagejpeg($thumb, "thumbnails/".$name, 80)) { //image-resource, filename, quality return 1; } imagedestroy($thumb); //destroy temporary image-resource imagedestroy($image); //destroy temporary image-resource } } function resizelarger($name){ $filename = './uploads/'.$name; if(file_exists($filename)) { $image = imagecreatefromjpeg($filename); //unresized image $im_info = getimagesize($filename); //unresized image $im_width = $im_info[0]; $im_height = $im_info[1]; $im_flag = $im_info[2]; //max height: 300px; max width: 300px if($im_width >= $im_height) { $im_divice = $im_width / 300; }else { $im_divice = $im_height / 300; } $thumb_width = $im_width / $im_divice; $thumb_height = $im_height / $im_divice; //create empty image $thumb = imagecreatetruecolor($thumb_width, $thumb_height); //resize image imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height); if(imagejpeg($thumb, "smallpics/".$name, 80)) { //image-resource, filename, quality return 1; } imagedestroy($thumb); //destroy temporary image-resource imagedestroy($image); //destroy temporary image-resource } } // make a note of the directory that will recieve the uploaded file // full url $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploads/'; $uploadsDirectory = './uploads/'; //Upload image $uploadFilename = $uploadsDirectory.$fieldname['name']; // now let's move the file to its final location and allocate the new filename to it move_uploaded_file($fieldname['tmp_name'], $uploadFilename); $user = ($_SESSION['MM_Username']); $to = 'admin@elvis-people.com'; //from you the sender. $from= 'admin@elvis-people.com'; //Subject line what ever. $subject = "New member with new photo"; $mess = "Username is $user, has tried uploading $uploadFilename"; $message = $mess; $headers = "From: $from\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // send if correct. mail($to, $subject, $message, $headers); $a = rand(1,99); resizeimage($fieldname['name']); rename("thumbnails/".$fieldname['name'], "thumbnails/".$user.$a.$fieldname['name']); $smallimage = './thumbnails/'.$user.$a.$fieldname['name']; resizelarger($fieldname['name']); rename("smallpics/".$fieldname['name'], "smallpics/".$user.$a.$fieldname['name']); $smallpics = './smallpics/'.$user.$a.$fieldname['name']; unlink($uploadFilename); $text = $_POST['textfield']; $wy = preg_replace ($search, $replace, $text); mysql_select_db($database_elvisdb, $elvisdb); $insertSQL = sprintf("INSERT INTO images (imageName, bigimagename, usnm, bigcaption) VALUES ('$smallimage', '$smallpics', '$user', '" . mysql_real_escape_string($wy) . "')"); $Result1 = mysql_query($insertSQL, $elvisdb) or die(mysql_error()); mysql_select_db($database_elvisdb, $elvisdb); mysql_select_db($database_elvisdb, $elvisdb); $query_Recordset2 = "SELECT * FROM images WHERE usnm='$logon'"; $Recordset2 = mysql_query($query_Recordset2, $elvisdb) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); mysql_select_db($database_elvisdb, $elvisdb); $query_Recordset4 = "SELECT * FROM userinformation WHERE usernm='$logon'"; $Recordset4 = mysql_query($query_Recordset4, $elvisdb) or die(mysql_error()); $row_Recordset4 = mysql_fetch_assoc($Recordset4); $totalRows_Recordset4 = mysql_num_rows($Recordset4); // send emmail $big = $row_Recordset2['bigimagename']; $username = $row_Recordset4['usernm']; $id = $row_Recordset4['id']; $email = $row_Recordset4['email']; // To who ever. $to = 'admin@elvis-people.com'; //from you the sender. $from= $email; //Subject line what ever. $subject = "New photo for elvis-people"; $mess = "Username is $username, record number is $id, photo is $big page www.elvis-people.com/allopic.php?name=$username"; $message = $mess; $headers = "From: $from\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // send if correct. mail($to, $subject, $message, $headers); $query_Recordset3 = sprintf("SELECT bigcaption FROM images WHERE usnm = '$user'"); $Recordset3 = mysql_query($query_Recordset3, $elvisdb) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); $capt = $row_Recordset2['bigcaption']; if (strlen($capt) >= 91) { header("Location: captlong.php?picnum=5"); } else { header("Location: esent.php"); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { color: #FFFFFF; } body { background-color: #000000; } #Layer2 { position:absolute; left:335px; top:138px; width:279px; height:57px; z-index:2; visibility: hidden; } #Layer1 { position:absolute; left:162px; top:146px; width:404px; height:105px; z-index:3; background-color: #000000; } .style1 {font-family: Helvetica, Arial, "Times New Roman"} #Layer3 { position:absolute; left:166px; top:19px; width:430px; height:254px; z-index:4; background-color: #000000; visibility: hidden; } .style3 { font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; } --> </style> <script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_showHideLayers() { //v6.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } obj.visibility=v; } } //--> </script> </head> <body> <div id="Layer1"></div> <div id="Layer3"> <h3><span class="style1">Uploading photo. Please wait. </span></h3> </div> <table width="100%" bgcolor="#000000"> <td width="130" align="left" valign="top"><img src="logo.gif" align="top" /> </td> <td ><table width="389" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#000000"> <TD> <form name="form1" id="Upload" action="<?php echo $editFormAction; ?>" enctype="multipart/form-data" method="POST"> <h3 class="style1"><span class="style3">Upload a photo of yourself, your favourite Elvis item, your Elvis room, or your favourite Elvis picture. Photo must be less than 1mb.</span></h3> <p> <input type="hidden" name="MAX_FILE_SIZE" value="2000000000"> </p> <h3> <input name="file" type="file" id="file" onchange="MM_showHideLayers('Layer1','','hide')" /> <span class="style1">for your photo</span> </h3> <p> <label> <input name="sent" type="hidden" id="sent" value="1" /> </label> </p> <h3 class="style7"> <input type="text" name="textfield" /> <span class="style2 style1">Add caption for the photo</span> </h3> <input name="submit" type="submit" id="submit" onclick="MM_showHideLayers('Layer1','','hide','Layer3','','show')" value="Upload your photo"> </p> <input type="hidden" name="MM_insert" value="form1"> </form></TD> </table> </td> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-328958 Share on other sites More sharing options...
phpknight Posted August 20, 2007 Share Posted August 20, 2007 Ignore the uploading issue for now. Give me the code that you would use to just do the resize/save. Obviously if that does not work, then there is no sense in wasting time uploading. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-328974 Share on other sites More sharing options...
Daniel0 Posted August 20, 2007 Share Posted August 20, 2007 Damn, that's a lot of replies... Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-328983 Share on other sites More sharing options...
phpknight Posted August 20, 2007 Share Posted August 20, 2007 Does that print statement thing work with other images? I have never done that. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329025 Share on other sites More sharing options...
garydt Posted August 20, 2007 Author Share Posted August 20, 2007 my resize script- function resizeimage($name){ $filename = './uploads/'.$name; if(file_exists($filename)) { ini_set('memory_limit', '500M'); set_time_limit ( 0 ); $image = imagecreatefromjpeg($filename); //unresized image $im_info = getimagesize($filename); //unresized image $im_width = $im_info[0]; $im_height = $im_info[1]; $im_flag = $im_info[2]; //max height: 140px; max width: 140px if($im_width >= $im_height) { $im_divice = $im_width / 140; }else { $im_divice = $im_height / 140; } $thumb_width = $im_width / $im_divice; $thumb_height = $im_height / $im_divice; //create empty image $thumb = imagecreatetruecolor($thumb_width, $thumb_height); //resize image imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height); if(imagejpeg($thumb, "thumbnails/".$name, 80)) { //image-resource, filename, quality return 1; } imagedestroy($thumb); //destroy temporary image-resource imagedestroy($image); //destroy temporary image-resource } } It works on small images but not on large ones, say over 2200pixels wide. Just to add, sometimes when i try uploading a large jpeg image it says it isn't a jpeg. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329029 Share on other sites More sharing options...
garydt Posted August 20, 2007 Author Share Posted August 20, 2007 yes, the print statement works with smaller images. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329032 Share on other sites More sharing options...
phpknight Posted August 20, 2007 Share Posted August 20, 2007 I am testing this now... Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329055 Share on other sites More sharing options...
phpknight Posted August 20, 2007 Share Posted August 20, 2007 Gary, I changed the directories and used a 5000x5000 pixel PNG and saved it as a jpg. I know you do not want to hear this, BUT it worked. Unless you have the directories messed up or something, I think it is a server configuration issue. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329066 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 LOL, yeah kinda had that thought awhile back.. but any idea, whats up with the server ? OK Good News and bad News Good News: I am at home and ran some tests, and it works Bad News: I didn't change much.. So i have PM'ed you a link to my test site it has a link to phpinfo() and the source code (little changes) files uploaded for you to test are:~ 1.1Mb File 2000x1303 (main file) 3.5Mb File 4000x2606 (doubled) 10.2mb File 8000x5212 (doubled) again Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329077 Share on other sites More sharing options...
garydt Posted August 20, 2007 Author Share Posted August 20, 2007 So when i call up the server company what should i ask them to check/change? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329100 Share on other sites More sharing options...
phpknight Posted August 20, 2007 Share Posted August 20, 2007 I have a few weird issues with the server, too...like mySQL server has gone away, lol. I am not sure what to ask them. If you have shared hosting, you'll probably just end up on hold for 40 minutes only to talk to somebody who doesn't know anything. Server issues are very difficult for me because they fall outside of programming. I would definitely just move servers over this one if they cannot fix it. There is really no excuse for it. The only thing I can thing of is something to do with the PHP ini. IF that were the case though, whatever memory limit error you would get should be logged right in a file as long as log_errors is on, which is should be. If not, they need to turn that on. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329107 Share on other sites More sharing options...
garydt Posted August 20, 2007 Author Share Posted August 20, 2007 ok, i'll call them up tomorrow and let you know the outcome. Theres a log directory on the server with files sucg as access.log, ftp.log, mail.log, but no error.log. Does that mean that error logging isn't on? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329123 Share on other sites More sharing options...
phpknight Posted August 21, 2007 Share Posted August 21, 2007 It depends on the setup actually. Display errors is on by default. But you really want the errors logged. That way, you can see fatal errors that might not show up otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-329466 Share on other sites More sharing options...
garydt Posted August 23, 2007 Author Share Posted August 23, 2007 I contacted my server and here's their reply- Thank you for contacting us. These are the default, acceptable valued in our shared server. Anything past these values will not increase the limits of your account. Module Version Expat 1.95.6 Sablotron 1.0 PCRE 4.5 OpenSSL 0.9.6 Libcurl 7.10.3 MySQL Client API 4 IMAP c-Client 4.1 GD 2.0 or higher (FreeType, TTF library, GIF Read/Create, JPG, PNG, WBMP) GDBM 1.8.0 Zlib 1.2.1 The php.ini file contains the following default values: upload_max_filesize:20M max_execution_time:300 memory_limit:40M post_max_size:8M SMTP:localhost This is almost without a doubt hitting one of our CGI limits. While you may be able to change some limits in PHP, we have hard CGI limits set for any CGI applications, PHP included. For reference, these are the limits which are imposed: * A process may only use a CPU at 100% for 6 seconds * A process may use a maximum of 12 mb of RAM * A maximum of 12 process to be run at any single time If any of these limits are surpassed, a 500 error will be displayed. It would be advisable at this time to optimize your scripts so that they use less resources from the server. If this usage were to increase in the future, it may be a sign that you need to consider upgrading to a dedicated server or VPS. These products provide a significantly larger amount of resources as compared to what is given with shared hosting and would likely eliminate any load problems like this. ----------------- Where do you think my problem lies and what do you think i should do? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-332357 Share on other sites More sharing options...
phpknight Posted August 26, 2007 Share Posted August 26, 2007 Gary, I think it is probably memory. I definitely would move to a different server if possible. If you can, you might want to consider a VPS. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-334324 Share on other sites More sharing options...
phpknight Posted October 2, 2007 Share Posted October 2, 2007 Gary, Did you ever switch servers? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/page/4/#findComment-359919 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.