Jump to content

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