SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    copy() ain't workin! Help!

    Ok, I have an upload script that "was" working before I moved it onto my new hosting service.
    The gist of it I was dev'ing this site, then funding fell through and I made a backup. And now, 2 years later I wanna toss it up on my current host.

    Basically I get this when I try to upload something
    Copy failed!
    ['error']
    House_Plant1054077319.jpg
    /home/webinfra/public_html/3dartisan/galleries/images/House_Plant1054077319.jpg
    Upload failed!
    ['error']

    Image entered into database successfully.

    Go to the gallery
    Or go return home
    Here's the code for the page:
    Code:
    <? // upload.php
    $section_pic = "img_upload.jpg";
    include('../head.php');
    include('../join_header.php');
    include('../error.php');
    Code:
    $uploadedfile = $_FILES['uploadedfile'];
    $uploadedfile_type = $_FILES['uploadedfile']['type'];
    $uploadedfile_name = $_FILES['uploadedfile']['name'];
    $uploadedfile_size = $_FILES['uploadedfile']['size'];
    $uploadedthumb = $_FILES['uploadedfilethumb'];
    $pic_name = $_POST['pic_name'];
    $pic_comments = $_POST['pic_comments'];
    $pic_author = $_POST['pic_author'];
    // Image Section
    $extension = ".jpg";
    if(!$pic_author){
    error("Please enter a name for the author");
    }
    if(!$pic_name){
    error("Please enter a name for the picture.");
    }
    if($uploadedfile=="none"){
    error("Please select an image to upload");
    }
    if( "image/pjpeg" == $uploadedfile_type ){
    echo "";
    } else {
    error(" We're sorry, but the image your uploading is not a .jpg image. Please try again.");
    }
    if(strlen($pic_comments) > 255){
    error("The comments you have entered contain too many characters. Please try again.");
    }
    if(!$pic_comments){
    $pic_comments = "No Comments";
    }
    $full_path = "/home/webinfra/public_html/3dartisan/galleries/images/";
    $spaceless_name = str_replace(" ", "_", $pic_name); // Remove spaces from filename for naming.
    $file_and_path = $full_path . $spaceless_name . time() . $extension;
    if(copy($uploadedfile, $file_and_path)){
    echo "Image uploaded successfully";
    } else {
    echo "<br />Copy failed!<br />";
    }
    $imageres = getimagesize($file_and_path);
    $filename = str_replace("/home/webinfra/public_html/3dartisan/galleries/images/", "", $file_and_path);
    echo $filename;
    echo "<br>$file_and_path";
    $pic_height = $imageres[1];
    $pic_width = $imageres[0];
    $date_added = date("Y-m-d");
    $time_added = date("H:i:s");
    // Thumb Section
    if($uploadedfile=="none"){
    error("Please select an image to upload");
    }
    if( "image/pjpeg" == $uploadedfile_type ){
    echo "";
    } else {
    error(" We're sorry, but the image your uploading is not a .jpg image. Please try again.");
    }
    if($uploadedthumb_size>40960){
    error(" We're sorry, but the image your uploading exceeds maximum file size. Please try again.");
    }
    $thumb_path = "/home/webinfra/public_html/3dartisan/galleries/thumbs/";
    $spaceless_name = str_replace(" ", "_", $pic_name); // Remove spaces from filename for naming.
    $thumb_and_path = $thumb_path . $spaceless_name . time() . $extension;
    if(copy($uploadedthumb, $thumb_and_path)){
    echo "<br>Thumbnail uploaded successfully";
    } else {
    echo "<br />Upload failed!<br />";
    }
    $filename = str_replace("/home/webinfra/public_html/3dartisan/galleries/images/", "", $file_and_path);
    $pic_url = "http://www.webinfractions.com/3darti...ages/$filename";
    $thumb_url = "http://www.webinfractions.com/3darti...umbs/$filename";
    
    $db_query="INSERT into gallery_pics (pic_name, pic_url, pic_author, pic_comments, thumb_url, pic_height, pic_width, date_added, time_added) VALUES ('$pic_name', '$pic_url', '$pic_author', '$pic_comments', '$thumb_url', '$pic_height', '$pic_width', '$date_added', '$time_added')";
    $db_connect = mysql_connect(localhost,*******,********);
    $db_name = "webinfra_3";
    if(mysql_db_query($db_name, $db_query, $db_connect)){
    echo "<br>Image entered into database successfully.";
    } else {
    echo "ERROR: Picture could not be entered into the database.";
    echo "<br><br>";
    echo mysql_error();
    }
    ?>
    <br>
    <br>
    <font size="2">Go to the <a href="/3dartisan/gallery_index.php">gallery</a><br>
    Or go return <a href="/3dartisan/index.php">home</a></font>
    <?
    include('../join_footer.php');
    mysql_close($db_connect);
    ?>
    I've verified that the paths are correct, both the /images and /thumbs directories are correct.

    I'm running php 4.3.1, Linux redhat.


    [Edit]Since vB is being STUPID and inserting font tags into php code, i'm using the code tag now.
    Last edited by Defender1; May 28, 2003 at 19:24.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When uploading, move_uploaded_file is preferable, I believe.

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's actually what I was using before. I changed it to copy hoping that was the problem :|
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try move_uploaded files.. and check CHMOD of the directory, and that it exists etc.

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Defender1
    I've verified that the paths are correct, both the /images and /thumbs directories are correct.
    Quote Originally Posted by Defender1
    That's actually what I was using before. I changed it to copy hoping that was the problem :|
    The directories in question are both 777.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well sorry for trying...


    Might I also ask why the font tags are in the middle of no where? Or is that some incorrect vB parsing?

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hrm... odd. vB put those in, not me.
    Fixed.

    Anyone else see a reason for it to not work?
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  8. #8
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code tag is just as stupid, it takes away line breaks. Why not upload a text file?

  9. #9
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would, but I solved my problem.
    I needed to use the $_FILES['uploadedfile']['tmp_name'] instead of $_FILES['uploadedfile'] but thx anyway.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

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