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

    Join Date
    Sep 2000
    Posts
    61
    Rep Power
    15
    I have a shopping cart that the owner will enter/edit inventory through an admin page. This all works but I wish to add a feature that would not require opening a seperate ftp program to upload the picture. I have investigated upload and ftp functions but don't know which way to go. I want the uploaded picture to be named xyz.gif (for product number xyz) automatically so the owner can't mess things up.

    That said, is either one of these methods better than the other for this type of job?

    Thanks

    [This message has been edited by stujohnson (edited December 02, 2000).]
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    you can always use a "file" field, and simply copy the selected file to the desired directory, for product pics.

    you can set a number of things by doing this, such as the files name, and what file mimes are acceptable, etc..

    Here's an example that I use to upload a banner image and store the file in a folder, and record the files name in a database.

    this is all done from a simple web form.

    #validate image_url
    if ($banner && ($image_url != "none")) {
    $imagename = $image_url_name;
    $imagesize = $image_url_size;
    $imagetype = $image_url_type;
    $size = GetImageSize($image_url);

    //verify appropriate MIME type
    $validmime = 0;
    for ($i = 0; $i < count($valid_mime); $i++) {
    if ($valid_mime[$i] == $imagetype) {
    $validmime = 1;
    }
    }
    #Check Top HxW
    if ($placement == "T" && $size[1] > $image_max_height) {
    //image is too tall//
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "The Banner Image is $size[1] pixels high, this height is not accepted, please try again.";
    }
    if ($placement == "T" && $size[0] > $image_max_width) {
    //image is too wide//
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "The Banner Image is $size[0] pixels wide, this width is not accepted, please try again.";
    }
    #Check Side HxW
    if ($placement == "S" && $size[1] > $image_max_height2) {
    //image is too tall//
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "The Banner Image is $size[1] pixels high, this height is not accepted, please try again.";
    }
    if ($placement == "S" && $size[0] > $image_max_width2) {
    //image is too wide//
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "The Banner Image is $size[0] pixels wide, this width is not accepted, please try again.";
    }
    if ($validmime == 0 &#0124; &#0124; $imagesize > $MAX_FILE_SIZE) {
    //appropriate mime not found//
    if ($validmime == 0) {
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "The Banner Image is of ($imagetype), this type of image is not accepted, please try again.";
    }
    //compare the selected upload file to the max value//
    if ($imagesize > $MAX_FILE_SIZE) {
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "The Banner Image ($imagename) you provided does not match our file size criteria, please try again.";
    }
    }
    if (!$missing_fields) {
    $imagename = date("U", time())."-".$imagename;
    if ($win32 == "Y") {
    if(!copy(stripslashes($image_url), $image_path.$imagename)) {
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "I was unable to upload your banner ($imagename) to the server, please try again.";
    }
    else {
    $image_url = $imagename;
    }
    }
    else {
    if(!copy($image_url, $image_path.$imagename)) {
    $missing_fields[] = "InvalidBanner";
    $image_url_error[] = "I was unable to upload your banner ($imagename) to the server, please try again.";
    }
    else {
    $image_url = $imagename;
    }
    }
    }
    }


    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.

IMN logo majestic logo threadwatch logo seochat tools logo