#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    145
    Rep Power
    15
    Please help me - I have looked all around and can not figure out how to do it. It is for an administration section so I do not need any bells and whistles, I do not need any error checking - I just need to upload files.

    I have a form that enteres information into a mySQL database and I want it to upload two images at the same time (a thumbnail and a main image). The images are already sized and ready to go - I just want to upload them when I submit the form and not just enter their names in the database and FTP the images.

    I have a script that processes the form, this is where I would need the help - if I have the image variables $thumbnail_image and $main_image - how do I get them to upload to my photo directory variable $AGPHTlocation.

    Any help in this matter would be appreciated and I would be glad to amend my script with your name for the assistance. I will be using this in other admin sections as well so that is why it is so important for me to figure this out.

    In the future, I will need it to handle eight photo uploads (I figure if it can handle two it can handle more).

    Please help.... please.

  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    NY, NY,USA
    Posts
    18
    Rep Power
    0
    here's some code that I use that seems to be working pretty well for me. I use the time() variable to create unique names--that way I don't have to go and check to see if an image by that name already exists.

    Here's my code for an image called graf1. Good luck.

    $upload_dir = "../img/press";

    if (ereg("none", $graf1) != 1){ //check to see if graf1 was filled in form
    $newimage = time()."graf1.".substr($graf1_name,-3); //create a unique name for the image $graf1, keeping the suffix (gif, jpg, png)
    $local_image = "$upload_dir/$newimage";
    copy($graf1, "$local_image"); //put the uploaded image in the right place
    Exec("chmod 755 $local_image"); //make the image world readable
    }

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    145
    Rep Power
    15
    I will try this today. Thanks. I think I understand your cose block and I will implement it into my form.

    Thank you again. Don't you love this forum and Open Source software!
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    NYC, USA
    Posts
    17
    Rep Power
    0
    Just went thro your request.
    If it is for uploading images into the MySQL database the code is right here.

    $image_name = "c:1419copy.jpg";//path of image
    $fp = fopen($image_name,"r") or die("open eror");
    $size = filesize($image_name);
    $picture = addslashes(fread($fp,$size));
    fclose($fp);
    $sql = "UPDATE products SET IMAGE = '$picture'
    WHERE
    PRODUCT_ID = '1'";
    $connect = mysql_connect("localhost","root","") or die("connect failed");

    $result = mysql_db_query("HOUSEOFPANACHE",$sql,$connect) or die("query failed");
    echo "insert success";



    This works very smoothly

Similar Threads

  1. Replies: 0
    Last Post: February 16th, 2004, 04:35 PM
  2. Uploading multiple images using paths all in same .txt file?
    By MarlboroMan in forum Perl Programming
    Replies: 3
    Last Post: February 3rd, 2004, 06:34 PM
  3. Uploading images
    By redstar in forum Perl Programming
    Replies: 3
    Last Post: January 4th, 2004, 10:34 PM
  4. uploading images.
    By -PROJECT- in forum Java Help
    Replies: 3
    Last Post: December 16th, 2003, 01:09 PM
  5. Image uploading butchering images
    By pablo.gosse in forum PHP Development
    Replies: 6
    Last Post: October 19th, 2003, 10:12 PM

IMN logo majestic logo threadwatch logo seochat tools logo