Jump to content

Recommended Posts

I am working on a file upload that stores the image in the database. my upload field is this:

<input type="file" name="image1[]" />

 

and my php to process the file and upload it is this:

$maxsize = 100000;

if(is_uploaded_file($_FILES['image1']['tmp_name'])) {

        //check the file is less than the maximum file size
        if($_FILES['image1']['size'] < $maxsize)
            {
         //prepare the image for insertion
        $imgData =addslashes(file_get_contents($_FILES['image1']['tmp_name']));
        $imgData = addslashes($_FILES['image1']);

         //get the image info..
          $size = getimagesize($_FILES['image1']['tmp_name']);

          $id = $name.'_'.$SKU;

         //our sql query
        $sql = "INSERT INTO Images
                ( imageID , Type ,Image, Size, FileName, DateAdded, Category, SKU. Description)
                VALUES
                ('".$id."', '".$size['mime']."', '".$imgData."', '".$size[3]."', '".$_FILES['image1']['name']."', NOW(), Fabric, '".$SKU."', '".$desc."'";

         echo $sql;
        // insert the image
        if(!mysql_query($sql)) {
            echo 'Unable to upload file';
            
        }
     }
    }
    else {
         // if the file is not less than the maximum allowed, print an error
         echo
          '<div>File exceeds the Maximum File limit</div>
          <div>Maximum File limit is '.$maxsize.'</div>
          <div>File '.$_FILES['image1']['name'].' is '.$_FILES['image1']['size'].' bytes</div>
          <hr />';
         } 

 

at first the sql just wouldn't work. Now I get this error every time for some reason

 

  Quote
File exceeds the Maximum File limit

Maximum File limit is 100000

File Array is Array bytes

 

which seems odd because it does not even return the file size or name correctly.

 

 

Link to comment
https://forums.phpfreaks.com/topic/227919-image-upload-problem/
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.