Jump to content

Recommended Posts

Hi,

 

I am trying to resize an image on upload the problem is that I think I am over complicating it by running a seperate function for each file type, added to the fact that I get an error which I will explain after the following code:

 

if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) { 
if (($HTTP_POST_FILES['userfile']['type'])=="image/gif"){
   function resizeImage($HTTP_POST_FILES['userfile']['type']))
   {
   
      $imgSize = getimagesize($HTTP_POST_FILES['userfile']['type']);
      $imgWidth = $imgSize[0];
      $imgHeight = $imgSize[1];
      $newWidth = "60";
      $newHeight = "60";
      
      $source = imagecreatefromjpeg($HTTP_POST_FILES['userfile']['type']);
      $thumb1 = imagecreatetruecolor($newWidth, $newHeight);
      
      imagecopyresized($thumb1, $source, 0, 0, 0, 0, $newWidth, $newHeight, $imgWidth, $imgHeight);
      header('Content-type: image/jpeg'); // <-- you need that!
      imagejpeg($thumb1);
   
   }
}
//After this point rename file and insert value to database.

 

As you can see I will need to run this function for every file type, gif, jpeg etc and I get an error: on the following line:

 

function resizeImage($HTTP_POST_FILES['userfile']['type']))

 

:

 

Parse error: parse error, unexpected '[', expecting ')'

 

Thanks,

 

 

G

Link to comment
https://forums.phpfreaks.com/topic/56852-image-resize-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.