I'm attempting to create an upload script using HTTP_upload (PEAR). Currently, the script definitely appears to work: There are no run-time or syntax errors. Everything appears to the user to be fine. The file even appears on the server as it should.
My problem is, any file that is uploaded via this script is almost completely unchangable via FTP. Basically, the only thing I can do through FTP is delete it. I can't move it. I can't change the CHMOD permissions. I can't even download it via FTP (I can, however, download it directly through the URL). So I'm at a loss...this script will be used a few times a day, so there will be a lot of files building up. I definitely want to be able to manage those files via FTP.
I've been screwing around with it for awhile; you guys are my last hope:
require_once("../PEAR/HTTP/Upload.php");
require_once("../PEAR/MIME/Type.php");
$upload = new HTTP_Upload("en");
$files = $upload->getFiles();
$file_num = 0;
foreach($files as $file){
$file_num++;
if (PEAR::isError($file)) {
echo "<p>".$file->getMessage()."</p>\r\n";
}
if ($file->isValid()) {
$x=1;
$file->setName("safe", time()."-");
while (file_exists($dir.$file->getProp("name"))) {
$x++;
$file->setName("safe", time()."-");
}
$dest_name = $file->moveTo($_SERVER['DOCUMENT_ROOT'].$dir);
if (PEAR::isError($dest_name)) {
echo "<p>".$dest_name->getMessage()."</p>\r\n";
}
// CHECK FILETYPE, IF INVALID
if ($file->getProp("ext") != "rar" && $file->getProp("type") != "application/zip") {
// DELETE FILE
@unlink($_SERVER['DOCUMENT_ROOT'].$dir.$file->getProp("name"));
echo "<p>Invalid file type. You may only upload rar or zip.</p>\r\n";
// IF VALID
} else {
$filename = $_info->site_url.substr($dir, 1).$file->getProp("name");
}
} else if ($file->isError()) {
echo "<p>".$file->errorMsg()."</p>";
}
}
Any ideas why this code would have such a result?
EDIT: To clarify, I get Permission Denied errors when I attempt any of those things I listed in FTP.