hi all
i posted a little while ago about this, but am getting no further ahead.
does anybody have a clue as to why this script doesn't upload my files any
longer (all it does is stick a 1kb file on the server which can't be read).
i'm not sure if the script thinks the file is only 1kb large or if the
problem is somewhere else. the server is freeBSD, PHP version 4. any
ideas? tks.
if(isSet($_POST['cmdUpload'])){
$sTargetDir = trim($HTTP_POST_VARS['destDir']);
$sOriginalFileName = $HTTP_POST_FILES['srcFile']['name'];
$sImgPrefix = trim($HTTP_POST_VARS['imgCategory']);
if($sTargetDir == "/public_html/images/" || $sTargetDir ==
"/public_html/ezine/images/"){ // it's an image - attach the image category
prefix //
$sFileName = $sImgPrefix . str_replace(" ", "_", $sOriginalFileName);
}
else{
$sFileName = str_replace(" ", "_", $sOriginalFileName);
}
$sFolder = str_replace("/public_html/", "", $sTargetDir);
$sFullDestinationPath = $sTargetDir . $sFileName;
if($_POST['destDir'] == ""){
die("Error: No destination directory selected. Upload aborted. Please
click your back button and try again.");
}
else{
$oFTPConn = ftp_connect($sFtpServer,21,9600) or die("Unable to connect to
$sFTPServer!"); //login to the ftp server and upload the file //
$cmdLogin = ftp_login($oFTPConn, $sFtpUserName, $sFtpPassWord) or
die("Unable to connect to login to the FTP server: $sFTPServer!");
$cmdUpload = FTP_NB_PUT($oFTPConn, $sFullDestinationPath,
$_POST['srcFile'], FTP_BINARY);
while ($cmdUpload == FTP_MOREDATA){
$cmdUpload = FTP_NB_CONTINUE($oFTPConn);
}
$cmdCloseFTP = ftp_close($oFTPConn);
if (!$cmdUpload){ //check to see if the file was successfully uploaded //
$sResponseMsg = "<h1>Error</h1><p>Unable to upload file to server.</p>";
}
else{
$sResponseMsg = "<span style='text-decoration:
underline;'>$sFileName</span> was uploaded successfull to $sTargetDir.";
}
}
}