Jump to content

[SOLVED] Setting Upload File size limit


darknessmdk

Recommended Posts

I've been working on a multiple file upload form for a few days now and finally got it working. However when I tried to set a file size limit it throws me errors.

[code] <?
if(isset($HTTP_POST_VARS['Upload'])) {


$discription = 'N/A';
$price = 'N/A';
$caption = 'N/A';

$uploaddir = "photography";

// ==============

// Upload Part

// ==============
//This is our size condition
if ($file_size > 1000000){
echo "Your file is too large";

} else {



foreach ($_FILES["photofile"]["error"] as $key => $error) {
if($error == UPLOAD_ERR_OK)

{
$tmp_name = $_FILES["photofile"]["tmp_name"][$key];

      $name = $_FILES["photofile"]["name"][$key];

      move_uploaded_file($tmp_name, "$uploaddir/$name");
 


$photo = "$uploaddir/$name";

$checked = $_POST['type2'];
foreach ($checked as $type) {


include("database.php");
$id = $_SESSION['id'];
$result = mysql_query("INSERT into valphoto(photo, caption, type, price, discription, id) VALUES('$photo', '$caption', '$type', '$price', '$discription', $id)");

}}}
if($result == TRUE) {
echo "Your Photos have been uploaded!";
} else {
echo "There was a problem uploading, Try again";
}
mysql_close($linkID);
}

}
?>[/code]

Something about the mysql_close($linkID); not being is not a valid connection?  Any help would be appreciated!
Link to comment
https://forums.phpfreaks.com/topic/36434-solved-setting-upload-file-size-limit/
Share on other sites

As the above poster said, you don't absolutely have to tell the connections to close. They will automaticly after the script is done.

But, the reason this is failing is probably because that var isn't the one set in your database.php file.

Look at example 1 here:
http://us2.php.net/mysql_close

Archived

This topic is now archived and is closed to further replies.

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