Results 1 to 3 of 3

Thread: Image Upload Issue

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Image Upload Issue

    Hello, I am trying to get my image upload script to work, but it keeps giving the error, here is the code:
    PHP Code:
    function uploadPic() {
            
    $path 'team_pics/';
            
    $uploadpath $path.basename($_FILES['imgfile']['name']);
            
            if (!
    move_uploaded_file($_FILES['imgfile']['tmp_name'], $uploadpath)) {
                die (
    'Error uploading the file!');
            }
            
            
    $img_name "$path".$_FILES['imgfile']['name'];
            
    $imageName $_FILES['imgfile']['name'];
            list(
    $width$height) = getimagesize($img_name);
            
    $new_name "team_pics/thum_".$_FILES['imgfile']['name'];
            
    $newImage "thum_".$_FILES['imgfile']['name'];
                
                    
    $new_width 155;
                    
    $new_height 90;
                
            
    $image_p imagecreatetruecolor($new_width$new_height);
            
    $image imagecreatefromjpeg($img_name);
            
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);
            
    imagejpeg($image_p$new_name100);
            echo 
    'image uploaded';

    It keeps throwing out the "Error uploading the file!" error. Any idea why? Thanks
    Thanks DD, you saved me countless times

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    try:

    move_uploaded_file($_FILES['imgfile']['tmp_name'], $uploadpath) or die ('Error uploading the file!');

    If that doesn't work the files might already exist, or the folder doesn't exist.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, I got it working, it was an error with the path. Thanks for the help
    Thanks DD, you saved me countless times

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
  •