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"); } } Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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/ Quote Link to comment 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 Quote Link to comment 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");} } ?> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 10, 2008 Share Posted March 10, 2008 try using imagecreatefromwbmp Quote Link to comment 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 Quote Link to comment 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"); } Quote Link to comment 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 Quote Link to comment 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.