| | |
Image resizing and uploading
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi this is nathen,
i think this is some what usefull to you,
i think this is some what usefull to you,
php Syntax (Toggle Plain Text)
if($_FILES[userfile][name]!='') { if($num<=0) { $rand=time(); $uploaddir="uploads/stores/"; $filetype2=$_FILES[userfile][type]; $filename=$_FILES[userfile][name]; $realpath=$uploaddir.$filename; if(!empty($filetype2)) { if(move_uploaded_file($_FILES['userfile']['tmp_name'],$realpath )) { } /************************************Resizing the image 75x75****************/ $path="uploads/stores"; $bgim_file_name = $path."/".$filename; $bgimage_attribs = getimagesize($bgim_file_name); if($filetype2=='image/gif') { $bgim_old = imagecreatefromgif($bgim_file_name); } else { $bgim_old = imagecreatefromjpeg($bgim_file_name); } $bgth_max_width = 75; //for Album image $bgth_max_height = 75; $bgratio = ($bgwidth > $bgheight) ? $bgth_max_width/$bgimage_attribs[0] : $bgth_max_height/$bgimage_attribs[1]; $bgth_width = 75;//$image_attribs[0] * $ratio; $bgth_height = 75;//$image_attribs[1] * $ratio; $bgim_new = imagecreatetruecolor($bgth_width,$bgth_height); imageantialias($bgim_new,true); $bgth_file_name = "uploads/stores/thumbnails/$filename"; imagecopyresampled($bgim_new,$bgim_old,0,0,0,0,$bgth_width,$bgth_height, $bgimage_attribs[0], $bgimage_attribs[1]); if($filetype2=='image/gif') { imagegif($bgim_new,$bgth_file_name,100); } else { imagejpeg($bgim_new,$bgth_file_name,100); } }
Last edited by peter_budo; Mar 26th, 2009 at 11:11 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- Image upload using php into mysql db (PHP)
- Problem with uploading images to website (PHP)
- Uploading and resizing images (PHP)
Other Threads in the PHP Forum
- Previous Thread: (urgent) help to display error message
- Next Thread: login redirection
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode up-to-date update upload url validator variable video web xml youtube






?