genista Posted June 23, 2007 Share Posted June 23, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/56852-image-resize-problem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.