Thread: FTP Upload

    #1
  1. No Profile Picture

    Join Date
    Jan 2002
    Location
    Pekin, IL
    Posts
    4
    Rep Power
    0

    FTP Upload


    I've been pouring over the following code all day, but can't seem to get it work. I appreciate anyone that can point out any errors.

    PHP Code:

        $imageUpFile 
    $_FILES['file']['tmp_name'];
        
    $imageType $_FILES['file']['type'];
        
    $imageName $_FILES['file']['name'];

        echo
    $imageUpFile$imageType$imageName";

        
        
    //Open the uploaded pic (temp file)
        
    if ($thePic fopen ($imageUpFile"rb"))
        {
             
    //read temp file into var
            
    $savePic fread($thePicfilesize($imageUpFile));
            
            
    //Open a new file in the correct directory using the name of the uploaded pic file
            
    if ($fileHandle fopen("ftp://username:apassword@somehost.com/htdocs/www/uploads/$imageName","w"))
            {
            
    //Put data into just opened file pointer
            
    if (fwrite ($fileHandle$savePic))
            {
            echo 
    "file <b>$imageName</b> successfully written";
            }
            else
            {
                        echo 
    "file <b>$imageName</b> was NOT written";
            }
            }
        
    fclose ($fileHandle);
        
    fclose ($thePic);
        }
        else
        {
            
    // The file was not created.  Inform the user.
            
    echo "<b> The file: $imageUpFile could not be created!</b>";
        } 
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    INDIA
    Posts
    17
    Rep Power
    0
    use instead the ftp functions.
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2001
    Location
    England
    Posts
    967
    Rep Power
    14
    Is there anything wrong with you using the copy() or move_uploaded_file() functions? It makes more sense to me to use this in your instance.

IMN logo majestic logo threadwatch logo seochat tools logo