Jump to content

Search the Community

Showing results for tags 'image upload and resize'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I need to upload 3 images and resize them as part of a forme but for some reason, the images does not end up in the server directory. What am i missing? The fille array looks like this: Array ( [file1] => Array ( [name] => s_casafolio.png [type] => image/png [tmp_name] => /tmp/phpENy7j4 [error] => 0 [size] => 2047496 ) [file2] => Array ( [name] => lawjournal.png [type] => image/png [tmp_name] => /tmp/phpT0fu1Y [error] => 0 [size] => 1139448 ) [file3] => Array ( [name] => s_mdj_2.png [type] => image/png [tmp_name] => /tmp/phpUsRk6W [error] => 0 [size] => 792873 ) ) And my processing looks like this: <?php $tmp = md5(md5(date("YmdHis"))); $img_quality = 70; $maxDim = 700; $dest_folder = "/home/user/public_html/userfiles/inscription_designer/"; $valid_mime_types_images = array( "image/gif", "image/png", "image/jpeg", "image/pjpeg", ); if (in_array($_FILES["file1"]["type"], $valid_mime_types_images)) { $ext = pathinfo($_FILES['file1']['name'], PATHINFO_EXTENSION); $dest_file = $dest_folder.$tmp.'1.'.$ext; $fn = $_FILES['file1']['tmp_name']; $size = getimagesize($fn); $ratio = $size[0]/$size[1]; // width/height if( $ratio > 1) { $width = $maxDim; $height = $maxDim/$ratio; } else { $width = $maxDim*$ratio; $height = $maxDim; } $src = imagecreatefromstring(file_get_contents($fn)); $dst = imagecreatetruecolor($width,$height); imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]); imagedestroy($src); imagepng($dst,$dest_file); // adjust format as needed imagedestroy($dst); }else{ $err .= "- Image 1 est invalide.<br />"; } if (in_array($_FILES["file2"]["type"], $valid_mime_types_images)) { $ext = pathinfo($_FILES['file2']['name'], PATHINFO_EXTENSION); $dest_file = $dest_folder.$tmp.'2.'.$ext; $fn = $_FILES['file2']['tmp_name']; $size = getimagesize($fn); $ratio = $size[0]/$size[1]; // width/height if( $ratio > 1) { $width = $maxDim; $height = $maxDim/$ratio; } else { $width = $maxDim*$ratio; $height = $maxDim; } $src = imagecreatefromstring(file_get_contents($fn)); $dst = imagecreatetruecolor($width,$height); imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]); imagedestroy($src); imagepng($dst,$dest_file); // adjust format as needed imagedestroy($dst); }else{ $err .= "- Image 2 est invalide.<br />"; } if (in_array($_FILES["file3"]["type"], $valid_mime_types_images)) { $ext = pathinfo($_FILES['file3']['name'], PATHINFO_EXTENSION); $dest_file = $dest_folder.$tmp.'3.'.$ext; $fn = $_FILES['file3']['tmp_name']; $size = getimagesize($fn); $ratio = $size[0]/$size[1]; // width/height if( $ratio > 1) { $width = $maxDim; $height = $maxDim/$ratio; } else { $width = $maxDim*$ratio; $height = $maxDim; } $src = imagecreatefromstring(file_get_contents($fn)); $dst = imagecreatetruecolor($width,$height); imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]); imagedestroy($src); imagepng($dst,$dest_file); // adjust format as needed imagedestroy($dst); }else{ $err .= "- Image 3 est invalide.<br />"; } ?>
×
×
  • 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.