geroid Posted June 4, 2009 Share Posted June 4, 2009 Hi I've been working on an image upload and resize script which I thought I had gotten to work. Problem is it only seems to work with jpg images. I want it to work with all image extensions. Error is that it's not a valid jpg file. Does anyone have a simple image upload script that works with all image types and resizes the image? I was using the 'imagecreatefromjpeg' function which I think is part of the problem. At this stage now I'd love some working script to learn from if it's possible!! Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/ Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 It shouldn't be to hard to ammend your current script. I have one that only like jpegs to Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849447 Share on other sites More sharing options...
geroid Posted June 4, 2009 Author Share Posted June 4, 2009 Do you know of a script that will work with images whatever their extension? Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849453 Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 not without typing it into google (im not using google for you) Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849456 Share on other sites More sharing options...
geroid Posted June 4, 2009 Author Share Posted June 4, 2009 In PHP do I have to determine the extension of the image file and then use the appropriate function like 'imagecreatefromjpeg' or 'imagecreatefrompng' or 'imagecreatefromgif' etc? Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849459 Share on other sites More sharing options...
Brian W Posted June 4, 2009 Share Posted June 4, 2009 yes, most people use a switch... Google it, there is 101+ scripts for it. Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849468 Share on other sites More sharing options...
geroid Posted June 4, 2009 Author Share Posted June 4, 2009 So if I extract the file extension I can then do a 'case''and use whatever function is appropriate right?? Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849469 Share on other sites More sharing options...
Brian W Posted June 4, 2009 Share Posted June 4, 2009 yes, a *switch*. http://www.devpapers.com/article/41 has an example of getting the file's extension within the context of an upload. Hope it helps Link to comment https://forums.phpfreaks.com/topic/160962-image-upload-problem/#findComment-849472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.