Results 1 to 8 of 8

Thread: Update a BLOB

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2009
    Posts
    49

    Re: Update a BLOB

    My old script that worked is in the first post.

    This inserted a BLOB into the database. With the new script I am trying to:

    1) upload the file to the server folder structure
    2) insert the filename into the image field in the product table

    (Which I assume my modified example code should be doing)

    Also my hoster told me file_uploads is on... I'm not sure why the $_FILES array is empty. The form isn't inside another form, the method is POST and the field is named as per the code (picture1).... is should be outputting something like:

    [picture1] => Array
    (
    [name] => filename.jpg
    ... etc
    )

    Just thinking about it I will need to create another field in the DB to store the filename varchar (rather then a BLOB). .... edit: Have now done this, though still getting the notice about picture1 not being defined and the array being empty.

    $picture1=mysql_real_escape_string($_POST['picture1']); shouldn't be stipping anything in the filename either? According to my error its got nothing to strip anyway

    Will keep looking as it must be something simple to get me past this early stage.
    Last edited by buffy; Jul 13th, 2009 at 05:41 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2009
    Posts
    49

    Re: Update a BLOB

    I have tried another simple example that seems to work for other people but not for me.

    This is the code:

    PHP Code:
    $uploaddir '/usr/../../products/';
    $filename $_FILES['picture1']['name'];
    $filesize $_FILES['picture1']['size'];
    $tmpname_file $_FILES['picture1']['tmp_name'];
    if(
    $filesize '5000000') {
    echo 
    "This file is to big to upload.";
    } else {
    move_uploaded_file($tmpname_file"$uploaddir$filename");
    echo 
    "Image upload successful to ".$uploaddir.$filename;

    The output is:

    Code:
    many Notice: Undefined index: picture1 in /../...php on line 217
    Image upload successful to /usr/.../products/
    But theres no image uploaded. Or filename added to database record. I also changed the code from ['picture1'] to [$picture1] and it said undefined index filename.jpg so I know its getting the information its just not getting it right. echo "testing $filename = " . $filename; outputs testing =

    Any help would be great... will have to go back to storing BLOBs if these simple examples don't work.

    Thanks
    Last edited by buffy; Jul 15th, 2009 at 03:32 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width