Jump to content

php multiple Image upload


desithugg

Recommended Posts

<head>
#############The Upload form file#########################
<script src="multifile_compressed.js"></script>
</head>
<body>
<form enctype="multipart/form-data" action="index.php?action=uploadimage2" method = "post">
<input size="50" id="my_file_element" type="file" name="images[]" >
<input type="submit" value="Upload">
</form>
Files:
<div id="files_list"></div>
<script>
var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10 );
multi_selector.addElement( document.getElementById( 'my_file_element' ) );
</script>
</body>

The code above is just a basic php upload form which uses javascript to upload multiple files using only one field

<?
#############The Upload action file#########################
$username = $_COOKIE['username'];	
while(list($key,$value) = each($_FILES[images][name]))
	{
		if(!empty($value))
		{
		srand((double)microtime()*1000000); 
                        $rand = rand(0,9999999);
		$rand2 = rand(0,999);
		$filename = $value;
		$add = "upimg/".$rand."".$username"".$rand2.".$filename";
		if(file_exists($_FILES[images][tmp_name][$key]) OR file_exists($add)
		{
		$error = $_FILES[images][type][$key]." already exists in the database.<br>";
		}
		if($error == "")
		{
                echo $_FILES[images][type][$key]." uploaded!";
		    echo "<br>";
				copy($_FILES[images][tmp_name][$key], $add);
				chmod("$add",0777);
		} 
		else
		{
		echo $error;
		}

		}
	}
?>

Now that's the code that handles the image upload but now what I want to do is make sure that all the images uploaded are

less than 550px in width how can I do that, I'm not sure how to get the image size of the uploaded files.

thanks in advace I g2g right now please try and help me out as quick as possible, kind of in a hurry.

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.