Jump to content

awebbdesigner

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by awebbdesigner

  1. Found the solution, needed to re-write my resize class to work off the temporary image upload and not the blob... The upload processing page <?php ini_set('display_errors', 1); error_reporting(E_ALL); include("../../connect.php"); include("resize.php"); # these settings should help set_time_limit(0); ini_set('upload_max_filesize', '12M'); ini_set("memory_limit", "16M"); # going in as a blob from now on $stamp = mktime(); $safename = $_FILES['Filedata']['tmp_name']; $filename = $_FILES['Filedata']['name']; $size = $_FILES['Filedata']['size']; $type = $_FILES['Filedata']['type']; $fk = $_REQUEST['fk']; # open and code into blob $fp = fopen($safename, 'r'); $content = fread($fp, filesize($safename)); $thumb = $content; $content = addslashes($content); fclose($fp); # find out what it is, uploadify send everything through as application, so we need to split the filename $fileExplode = explode('.', $filename, 3); $fileExtension = strtolower($fileExplode[1]); if($fileExtension == 'jpg' xor $fileExtension == 'png' xor $fileExtension == 'gif') { # find out image size and create thumbnails... 800 400 100 list($width, $height) = getimagesize($safename); if ($width > $height) { $orientation = "landscape"; } elseif ($width < $height) { $orientation = "portrait"; } else { $orientation = "square"; }; # max width/height = 800 $eight = new resize($safename, $width, $height, 800); $four = new resize($safename, $width, $height, 400); $one = new resize($safename, $width, $height, 150); } $iS = "INSERT INTO $tableb (pal, afield, bfield, cfield, dfield, efield, ffield, gfield, ablob, bblob, cblob, dblob) VALUES ('6', '$fk', '$filename', '$size', '$fileExtension', '$width', '$height', '$orientation', '$content', '$eight->new_image_blob', '$four->new_image_blob', '$one->new_image_blob')"; $iQ = mysql_query($iS) or die (mysql_error()); print "1"; // print "<p>$eight->new_image_blob</p>"; ?> The class I wrote to solve resize the images into blobs... <?php class resize { public $new_image_blob = "--"; function __construct($image_file, $width, $height, $amount) { # the maximum width and height as set by the user $thumb_height_max = $amount; $thumb_width_max = $amount; # maintain aspect ratio landscape or portrait if($width < $height) { $new_width = ($thumb_height_max / $height) * $width; $new_height = $thumb_height_max; $needtoresize = ($height < $thumb_height_max); } else { $new_width = $thumb_width_max; $new_height = ($thumb_width_max / $width) * $height; $needtoresize = ($width < $thumb_width_max); } $src = imagecreatefromjpeg($image_file); $tmp = imagecreatetruecolor($new_width,$new_height); imagecopyresampled($tmp,$src,0,0,0,0,$new_width, $new_height,$width,$height); # get the image, then re-convert ob_start(); imagejpeg($tmp, NULL, 100); $final_image = ob_get_contents(); ob_end_clean(); # this should be it $this->new_image_blob = addslashes($final_image); } } ?>
  2. Hi I have create a script that adds a image as blob successfully, however now I want to create a thumbnail, I have the following code; can someone help... # open and code into blob $fp = fopen($safename, 'r'); $content = fread($fp, filesize($safename)); $thumb = $content; $content = addslashes($content); fclose($fp); # resize accordingly... $thumb = new resize($content, $width, $height, 300); # the class that does the resizing (WHERE I THINK ITS GONE WRONG) class resize { public $new_image_blob = ""; function __construct($blob, $width, $height, $amount) { # the maximum width and height as set by the user $thumb_height_max = $amount; $thumb_width_max = $amount; # maintain aspect ratio landscape or portrait if($width < $height) { $new_width = ($thumb_height_max / $height) * $width; $new_height = $thumb_height_max; $needtoresize = ($height < $thumb_height_max); } else { $new_width = $thumb_width_max; $new_height = ($thumb_width_max / $width) * $height; $needtoresize = ($width < $thumb_width_max); } # now that we have the new width and heightwe need to resize the blob $im = imagecreatefromstring($blob); $thumb = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($thumb, $im, 0, 0, 0, 0, $new_width, $new_height, ImageSX($im), ImageSY($im)); $this->new_image_blob = addslashes($thumb); } } # then the query below adds the code (the original blob goes in correctly (ablob) but bblob (the resized blob doesn't)) $iS = "INSERT INTO $tableb (pal, afield, bfield, cfield, dfield, efield, ffield, gfield, ablob, bblob, cblob, dblob) VALUES ('6', '$fk', '$filename', '$size', '$fileExtension', '$width', '$height', '$orientation', '$content', '$thumb->new_image_blob', '$four', '$two')";
  3. An update before I mark as solved. I wasn't able to update the max_allowed_packets during runtime locally on my mac using MAMP so I had to copy over a .cnf file and restart which worked a treat. Thankfully MOSSO cloud supports max_allowed_packets during runtime, so I can now upload upto 16mb into blob fields. This link was helpful for me to upload above 1mb locally on my Mac using MAMP: http://forum.mamp.info/viewtopic.php?f=2&t=6306 Thanks for all the help.
  4. I added the following code... # helpful info $x = mysql_query("SELECT @@max_allowed_packet"); $y = mysql_fetch_array($x); print "<p>Max allowed packet is: " . $y[0]. "</p>"; And I got... Max allowed packet is: 1048576 The file I am trying to upload is Size: 1623807 So its definitely the packets. I have googled around and found a few solutions, one way is to split the file into chunks. I am going to try that and update this post with progress in case it's handy for others.
  5. I have changed the script to the following... <?php ini_set('display_errors', 1); error_reporting(E_ALL); include("../../connect.php"); # these settings should help set_time_limit(0); # going in as a blob from now on $stamp = mktime(); $safename = $_FILES['Filedata']['tmp_name']; $filename = $_FILES['Filedata']['name']; $size = $_FILES['Filedata']['size']; $type = $_FILES['Filedata']['type']; $fk = $_REQUEST['fk']; $sqlname = $stamp . "-" . $_FILES['Filedata']['name']; /// open and code in $fp = fopen($safename, 'r'); $content = fread($fp, filesize($safename)); $content = addslashes($content); fclose($fp); $big = mysql_query("SET max_allowed_packet=16777216"); $insertS = "INSERT INTO $tableb (pal, afield, bfield, cfield, dfield, efield, ffield, ablob) VALUES ('6', '$fk', '$filename', '$size', '$type', '$width', '$height', '$content')"; $errQ = mysql_query("INSERT INTO $tableb (pal, atext) VALUES ('1', '$insertS')"); $insertQ = mysql_query($insertS); print "<p><strong>Safename:</strong> $safename, <strong>Size:</strong> $size</p>"; print "<p><em>$insertS</em></p>"; print "1"; ?> I got... Safename: /Applications/MAMP/tmp/php/phpmIOmby, Size: 1846539 Then the query which looks fine, when I try to run the query printed in navicat it doesn't insert a row or give me an error message. I suspect this is to do with mysql not allowing posts over 1mb, so please can someone tell me the code to write in PHP that can overwrite this 1mb limit?
  6. When I upload an image 1mb or less, I can see the row in the table (name, description, blob image). However when I try to upload and image above 1mb there is now row added in the table, not even the description. Its like it doesn't like an image over 1mb and then just fails. Hope this is clear.
  7. I still can't get any further information, you mentioned packet size whichI googled, couldn't make heads or tails of it, is there anyway of changing it from 1mb to say 10mb during runtime? if so can you write an example?
  8. I will endeavor to get more error messages shortly as I am not familiar with error_log $insertS = "INSERT INTO $tableb (pal, afield, bfield, cfield, dfield, efield, ffield, ablob) VALUES ('6', '$fk', '$filename', '$size', '$type', '$width', '$height', '$content')"; $insertQ = mysql_query($insertS); I have added... $errQ = mysql_query("INSERT INTO $tableb (pal, atext) VALUES ('1', '" . mysql_error($insertQ) . "')"); However the text field is blank, have I written it correctly?
  9. I should of mentioned that I am making this request using ajax (Jquery Uploadify) so its hard for me to see the error, I will try a separate query though.
  10. Hi All, Having issues uploading files larger than 1mb. This is what I have currently as default when I ran phpinfo() (working locally on my machine)... upload_max_filesize: 432M post_max_size: 432M memory_limit: 8M max_input_time: 60 max_execution_time: 30 I'm looking for the file to be converted into a blob, it works perfectly fine for files less than 1mb, but doesn't even run the mysql query above that. Any Ideas anyone? include("../../connect.php"); # these settings should help set_time_limit(0); # going in as a blob from now on $stamp = mktime(); $safename = $_FILES['Filedata']['tmp_name']; $filename = $_FILES['Filedata']['name']; $size = $_FILES['Filedata']['size']; $type = $_FILES['Filedata']['type']; $fk = $_REQUEST['fk']; $sqlname = $stamp . "-" . $_FILES['Filedata']['name']; # open and code in $fp = fopen($safename, 'r'); $content = fread($fp, filesize($safename)); $content = addslashes($content); fclose($fp); $insertS = "INSERT INTO $tableb (pal, afield, bfield, cfield, dfield, efield, ffield, ablob) VALUES ('6', '$fk', '$filename', '$size', '$type', '$width', '$height', '$content')"; $insertQ = mysql_query($insertS); print "1";
  11. Just ran a test on a more recent server and found it worked straight away. I will mark this topic as solved as it looks like it was to do with an old mysql version rather than the code itself. Many thanks to all who have helped.
  12. I have tried using %d and %e both with no success. I tried putting a zero in front with also no success. Strange thing is I changed the value to 2010-08-09 00:00:00 Making the value I was looking for to '9' I then did a between test of the following... 1 - 9 = worked. 8 - 9 = worked. 9 - 10 = failed. The only thing I can think of is MYSQL doesn't like using between date formats from 1 digit to 2 digits. The MYSQL version is 3.23 so I wondered whether that was the issue (currently exploring)
  13. Many thanks for your swift response. I have just ran a few tests and seem to have unusual results, when i try... SELECT * from company WHERE so <> 0 AND so_active = 'yes' AND DATE_FORMAT(so_start_date, '%e') BETWEEN 5 AND 22 ORDER BY company_name ASC It doesn't work, however... SELECT * from company WHERE so <> 0 AND so_active = 'yes' AND DATE_FORMAT(so_start_date, '%e') BETWEEN 16 AND 20 ORDER BY company_name ASC Works fine (the company returned has a %e = 18) so it seems like MYSQL doesn't like the between statement if its between range is too large. The so_start_date column is a standard 'datetime' type (YYYY-m-d H:i:s). I am a bit puzzled but I think we are nearly there.
  14. Sorry, I just tried that and it didn't return any results. i also shortened the query for testing purposes to... SELECT * from company WHERE DATE_FORMAT(so_start_date, '%e') BETWEEN 4 AND 20 ORDER BY company_name ASC Any help would be much appreciated.
  15. Hi all, I have done a script that works fine on a single basis... SELECT * FROM company WHERE so <> 0 AND so_active = 'yes' AND DATE_FORMAT(so_start_date, '%e') = '18' ORDER BY company_name ASC The problem I have is when I try to do a range... SELECT * FROM company WHERE so <> 0 AND so_active = 'yes' AND DATE_FORMAT(so_start_date, '%e') BETWEEN '5' AND '26' ORDER BY company_name ASC It should return at least 1 result as I am looking for '18', any help would be much appreciated. Many Thanks.
  16. Hi... I have an array '$names' with the following... Array ( [un] => a [pa] => v ) However this array gets used in a for loop and I need to pull the value out using a number i.e. $myname = $names[1] // should print out v When I try this it fails, any tips would be helpful. Or if there is a function for converting array keys into numbers?
  17. I was just wondering whether it was possible to use array_walk on a function name that is variable... or some other method for passing an array to a variable function /// run the function $func = "$this->$funD->afield"; array_walk($arg_array, "$func"); I googled around without much luck.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.