acctman Posted March 10, 2008 Share Posted March 10, 2008 I'm not able to test the coding below yet, but can someone read over it and tell me if it will work? thanks $upload_path = "/home/site/public_html/temp/"; $filename = $_FILES['Filedata']['tmp_name']; $ext = explode(".", $filename); $ext = $ext[count($ext)-1]; if ($_GET['type'] == 'reg') { if($ext == '.jpg') // if jpg do nothing if($ext == '.gif') $res = ImageCreateFromGIF($_FILES['Filedata']['tmp_name']); imagejpeg($res, $newname); if($ext == '.bmp') $res = ImageCreateFromBMP($filename); imagejpeg($res, $newname); imagedestroy($res); if(!move_uploaded_file($newname, $upload_path . session_id() . $ext)) { header("HTTP/1.0 500 Internal Server Error"); } } Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/ Share on other sites More sharing options...
mikefrederick Posted March 10, 2008 Share Posted March 10, 2008 use curly brackets with your if statements. also, it might not be a great idea to use $ext = $ext[count($ext)-1]; you might consider using a variable name other than $ext. Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488246 Share on other sites More sharing options...
KrisNz Posted March 10, 2008 Share Posted March 10, 2008 ImageCreateFromBMP is not a function. Theres imagecreatefromwbmp, which is for creating wireless bitmaps, not windows ones. Why can't you test it? Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488285 Share on other sites More sharing options...
Lumio Posted March 10, 2008 Share Posted March 10, 2008 It won't work anyway. You're using explode with a dot as pattern. So if you got a filename as text.gif it get splitted up to Array ( [0] => text [1] => gif ) So the dot is not there. Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488286 Share on other sites More sharing options...
acctman Posted March 10, 2008 Author Share Posted March 10, 2008 can someone assist me with correcting the problems with this piece of coding... also how would i convert a bmp to jpg? I can't test this because i'm on a umpc and dont have access to a webserver as of now to test Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488737 Share on other sites More sharing options...
discomatt Posted March 10, 2008 Share Posted March 10, 2008 Assuming you're running windows... get WAMP and run your own server from the UMPC http://www.wampserver.com/en/ Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488742 Share on other sites More sharing options...
acctman Posted March 10, 2008 Author Share Posted March 10, 2008 Assuming you're running windows... get WAMP and run your own server from the UMPC http://www.wampserver.com/en/ can you assist with help me rewrite this code so it works properly? I would help out a lot Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488868 Share on other sites More sharing options...
darkfreaks Posted March 10, 2008 Share Posted March 10, 2008 <?php $upload_path = "/home/site/public_html/temp/"; $filename = $_FILES['Filedata']['tmp_name']; $ext = $ext[count($ext)-1]; if ($_GET['type'] == 'reg') { if($ext == '.jpg'){ // if jpg do nothing } elseif($ext == '.gif'){ $res = ImageCreateFromGIF($_FILES['Filedata']['tmp_name']); imagejpeg($res, $newname);} elseif($ext == '.bmp'){ $res = ImageCreateFromBMP($filename); imagejpeg($res, $newname); imagedestroy($res);} if(!move_uploaded_file($newname, $upload_path . session_id() . $ext)) { header("HTTP/1.0 500 Internal Server Error");} } ?> Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488875 Share on other sites More sharing options...
acctman Posted March 10, 2008 Author Share Posted March 10, 2008 if(!move_uploaded_file($newname, $upload_path . session_id() . $ext)) the $ext should the be ".jpg" instead since i'm changing all files to jpg? Also someone above mentioned that "ImageCreateFromBMP" would not work from changing .bmp to .jpg Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488885 Share on other sites More sharing options...
darkfreaks Posted March 10, 2008 Share Posted March 10, 2008 try using imagecreatefromwbmp Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488891 Share on other sites More sharing options...
acctman Posted March 10, 2008 Author Share Posted March 10, 2008 try using imagecreatefromwbmp according to http://us2.php.net/imagecreatefromwbmp thats for wireless bmp and not windows bmp Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488910 Share on other sites More sharing options...
acctman Posted March 10, 2008 Author Share Posted March 10, 2008 can i use ImageMagick and do something like elseif($ext == '.bmp'){ $res = exec(convert $filename $newname . ".jpg"); } Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-488941 Share on other sites More sharing options...
acctman Posted March 11, 2008 Author Share Posted March 11, 2008 anyone have 5mins to spare to help me finish this up Link to comment https://forums.phpfreaks.com/topic/95325-coding-check-will-this-work/#findComment-489088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.