neugi Posted August 2, 2006 Share Posted August 2, 2006 Hi i got 4 pics that i want to upload into my data base. but after is press the upload button it makes "pong" (sound) and nothing happens.here is the code i wrote:[code]function bildklein($bild, $width) { $img = imagecreatefromstring($bild); $img_b = imagesx($img); $img_h = imagesy($img); $new_h = ($img_b / $img_h) * $width ; $newimg = imagecreatetruecolor($width, $new_h); imagecopyresized ($newimg, $img, 0, 0, 0, 0, $width, $new_h, $img_b, $img_h); return imagejpeg($newimg, '', 80); }for ($i = 0; $i <=3; $i++) { if ($_FILES[bild][error][$i] == 0 ) { $bildString = addslashes(fread(fopen($_FILES[bild][tmp_name][$i], "r"),$_FILES[bild][size][$i])); //echo $bildString; $bild_data = bildklein($bildString, "400"); echo $bild_data; //$bildInsert = mysql_query ("INSERT INTO ref_bilder (bild) VALUES ('$bild_data')",$link); if ($bildInsert){ echo 'Bild: '.$_FILES[bild][name][$i].' hochgeladen!'; } } }[/code]what is wrong? maybe somebody can help methx Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/ Share on other sites More sharing options...
PHPSpirit Posted August 2, 2006 Share Posted August 2, 2006 "pong" :DDeclare your database and remove the comments ( // ). Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/#findComment-67907 Share on other sites More sharing options...
neugi Posted August 3, 2006 Author Share Posted August 3, 2006 if i remove the comments in front of the insert into the db also nothing happens. i think the problem is the bildklein function because if i remove the call of bildklein function it works but than i've got the wrong data in the database.is there a better way to resize the pic bevore i insert it into the database?best Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/#findComment-68347 Share on other sites More sharing options...
manmadareddy Posted August 3, 2006 Share Posted August 3, 2006 I hope this kind of resize will loose the qualityIt is better to use ImageMagick for resizingthe images. Its very easy process,Just we need to execute commands throughour php code. Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/#findComment-68352 Share on other sites More sharing options...
neugi Posted August 3, 2006 Author Share Posted August 3, 2006 and if ImageMagick is not supportet on the host ?best Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/#findComment-68354 Share on other sites More sharing options...
manmadareddy Posted August 3, 2006 Share Posted August 3, 2006 just use imagefactory functions from phpclasses.orgI hope that will solve ur problem. Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/#findComment-68359 Share on other sites More sharing options...
neugi Posted August 3, 2006 Author Share Posted August 3, 2006 okay, found a way that works for me:[list][*]i upload the pic to a directory[*]resize the pic and copy it to a tmp directory[*]delete the original[*]open the resized image and copy it to the database[*]after insert in db was okay delete the the resized img form the tmp folder[/list]best Link to comment https://forums.phpfreaks.com/topic/16329-resize-pic-an-upload-in-db/#findComment-68533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.