How to upload files via a php script on a plesk server?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Scott Evans
    New Member
    • Nov 2010
    • 9

    How to upload files via a php script on a plesk server?

    The error I have been getting is either (when I switch the $_FILES['uploadfile']['name'] (originally at top where tmp_name is)
    Warning:ftp_put (C:\Inetpub/vhosts/dumountaineer.c om/httpdocs/dbimage/log.gif) [function.ftp-put]: failed to open stream: No such file or directory in C:\Inetpub\vhos ts\dumountainee r.com\httpdocs\ todb.php on line 21

    or Access Denied when I switch back.

    Code:
    <?php
    $tmp=$_FILES['uploadfile']['tmp_name'];
    $password="pass"; //not real of course
    $user="user"; //not real of course
    $server="localhost";
    $connection=ftp_connect($server);
    $login=ftp_login($connection,$user,$password);
    if($login)
    {
    //it says it connected and says Attempting to Load: thefile.something
    
    echo "Connected";
    echo "Attempting to Load:";
    echo $tmp;
    }
    else if (!$login)
    {
    echo "Could not Establish Connection <br />";
    }
    
    $directory="C:\Inetpub/vhosts/dumountaineer.com/httpdocs/dbimage/".$_FILES['uploadfile']['name']; //any way i do this it fails to upload
    
    if(ftp_put($connection,$tmp,$directory,FTP_BINARY)){
    echo "Thanks! Succesful Upload";
    }
    else 
    {
    echo "Failed Upload";
    }
    ftp_close($connection);
    ?>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You need to escape that backslash in the directory variable.

    Comment

    • Scott Evans
      New Member
      • Nov 2010
      • 9

      #3
      thanks works.

      Comment

      Working...