Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Resize the images after uploading! -


html form

<form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" /><p /><input type="submit" value="uplaod" /> </form> 

php function

function createresizedimk($img, $imgpath, $thumbdir, $suffix, $by) {   // add in suffix after '.' dot.     $newnamee = explode(".", $img);     $newname = ''. $newnamee[0] .''. $suffix .'.'. $newnamee[1] .'';    // imagemagick doesnt '/' , 'x' characters in command line call.   // , workout size based on '$by'.     $uploadedimg = ''. $imgpath .'/'. $img .'';     $newresized = ''. $reducedir .'/'. $newname .'';     list($width, $height, $type, $attr) = getimagesize("$imgpath/$img");     $newwidth = ($width/$by);     $newheight = ($height/$by);     $newres = ''. $newwidth .'x'. $newheight .'';    // makes command line call imagemagick.   // path imagemagick convert '/usr/lib/php/bin/convert'   // 'convert' program (unix) no forward slash.     $cr = system("/usr/lib/php/bin/convert -resize $newres $uploadedimg $newresized", $retval);      return $cr; } 

upload.php

$imgdir  ="uploads"; $resdir  ="resized"; $thumbdir="thumbs";  $img     = $_files['file']['name']; $tmppath = $_files['file']['tmp_name'];  if (move_uploaded_file($tmppath,"$imgdir/$img")) { $resize = createresizedimk($img, $imgdir, $resdir, "resized-", 2); $thumb  = createthumbimk($img, $imgdir, $thumbdir, "thumb-", 150, 150); } 

this create 3 images "the original,resized 1 , thumbnail",

  • /uploads/$img
  • /resized/$img
  • /thumbs/$img

how can make create 2 images (resized 1 , thumbnail) out original image!

  • /resized/$img
  • /thumbs/$img

thank you,

you can delete uploaded file right after creation of resized , thumb file with

unlink($imgdir .'/'. $img); 

right after

$thumb  = createthumbimk($img, $imgdir, $thumbdir, "thumb-", 150, 150); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -