Jump to content

Coding check, will this work?


acctman

Recommended Posts

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
Share on other sites

<?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
Share on other sites

 

 

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