SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: path to file

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    path to file

    I'm sending a pathname ($myMedia) from a browse box through flash to this php file for uploading the file to my ftp.
    I get the output that the filepath can't be understood, so I'm wondering if I should process the path before the upload starts in any way?

    PHP Code:
    <?php
    class UploadToFtp
    {
        function 
    uploadFile($myMedia)
        {
            
    // set up basic connection
            
    $conn_id ftp_connect("ftp.myserver.com");

            
    // login with username and password
            
    $login_result ftp_login($conn_id"user""pass");

            
    $source_file $myMedia;
            
    $destination_file 'someName.jpg';

            
    // upload the file
            
    $upload ftp_put($conn_id$destination_file$source_fileFTP_BINARY);

            
    // check upload status
            
    if (!$upload) {
                    return 
    'Not uploaded';
                } else {
                    return 
    'Uploaded';
                }

            
    // close the FTP stream
            
    ftp_close($conn_id);
        }
    }
    ?>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Is this the whole script? Where do you create an instance of the class? And where do you call the function?

    Did you try and echo the value of $myMedia? Is it correct?

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes this is the whole script, but I'm using AMFPHP so this is just a service file, all the backend stuff is predefined in the AMFPHP folders..

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by lammspillning View Post
    Yes this is the whole script, but I'm using AMFPHP so this is just a service file, all the backend stuff is predefined in the AMFPHP folders..
    Ok
    So, do you have the possibility to check the value of $myMedia that arrives at the function?

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it seems that it only returns the name of the file, not the path to it..


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
  •