
What the...? - Problems with FTP_PUT
I've got a form which lets users select and then FTP_PUT a .PPT doc up to
the server into a directory specified by them. It works on the local box,
but from a remote connection I get:
Warning: error opening C:\\docs\\test.ppt in ftpup.php on line 55
Line 55 is:
$upload = ftp_put($conn_id, stripslashes($parentDir . "/" . $subDir . "/" .
$theFile), $file, FTP_BINARY);
Here's the whole thing:
...FTP login stuff...
$parentDir = $dir;//parent directory where the file is going
$subDir = $userName;//sub directory for file
$file = $fileName;//the file
//the fileName variable has the complete directory path so
//we must strip off everything but the name of the file itself
//in order to give the ftp_put command a name for new file
$theFile = explode("\\", stripslashes($fileName));
$theFile = end($theFile);
//get the extension of the file and reject if its not powerpoint
$ext_array = explode(".",$theFile);
$last_position = count($ext_array) - 1;
$ext = $ext_array[$last_position];
if($ext == "ppt"){
//go ahead and upload it
echo "parentDir = " . $parentDir . "<br>";
echo "subDir = " . $subDir . "<br>";
echo "file = " . $file . "<br>";
//if the directory doesn't exist yet make one
ftp_mkdir($conn_id, $subDir);
Quote:
}
//upload the file into the directory
//----------------------------------------------------------------
//$file = stripslashes($file);
$upload = ftp_put($conn_id, stripslashes($parentDir . "/" . $subDir . "/" .
$theFile), $file, FTP_BINARY);
echo "<br><br><strong>file : </strong> " . $file . "<br>";
echo "<strong>Going to : </strong> " . stripslashes($parentDir . "/" .
$subDir . "/" . $theFile) . "<br>";
echo "<strong>Parent Dir : </strong> " . $parentDir . "<br>";
echo "<strong>Sub Dir : </strong> " . $subDir;
flush();
if (is_file($theFile)){
echo "<p><strong>Upload Successful</strong></p>";
Quote:
}else{
echo "<br><strong>FAILED</strong>";
Quote:
}
flush();
// close the FTP stream
ftp_quit($conn_id);
Quote:
}else{
//the extension was not ppt - Kick em out
// close the FTP stream
ftp_quit($conn_id);
header ("location: index.php?avar=badext");
Quote:
}
Can anyone offer guidance?
TIA,
Seth