Hello,
Here is part of the code in clsUpload.php:
function save($directory, $field, $overwrite,$mode=0777)
{
$this->isPosted = true;
if ($this->HTTP_POST_FILES[$field]['size'] < $this->maxupload_size && $this->HTTP_POST_FILES[$field]['size'] >0)
{
$noerrors = true;
$this->isPosted = true;
// Get names
$tempName = $this->HTTP_POST_FILES[$field]['tmp_name'];
$file = $this->HTTP_POST_FILES[$field]['name'];
$all = $directory.$file;
// Copy to directory
if (file_exists($all))
{
if ($overwrite)
{
@unlink($all) || $noerrors=false; $this->errors = "Upload class save error: unable to overwrite ".$all."<BR>";
@move_uploaded_file($tempName,$all) || $noerrors=false; $this->errors .= "Upload class save error: unable to copy to ".$all."<BR>";
@chmod($all,$mode) || $ernoerrorsrors=false; $this->errors .= "Upload class save error: unable to change permissions for: ".$all."<BR>";
}
} else{
@move_uploaded_file($tempName,$all) || $noerrors=false;$this->errors = "Upload class save error: unable to copy to ".$all."<BR>";
@chmod($all,$mode) || $noerrors=false;$this->errors .= "Upload class save error: unable to change permissions for: ".$all."<BR>";
}
return $noerrors;
} elseif ($this->HTTP_POST_FILES[$field]['size'] > $this->maxupload_size) {
$this->errors = "File size exceeds maximum file size of ".$this->maxuploadsize." bytes";
return false;
} elseif ($this->HTTP_POST_FILES[$field]['size'] == 0) {
$this->errors = "File size is 0 bytes";
return false;
}
}
and my code:
//--------- Upload file
include("clsUpload.php");
$upload = new Upload($HTTP_POST_FILES);
$upload->maxupload_size = 38000;
$location_server=$DOCUMENT_ROOT."/parties/images/";
if ($upload->save($location_server,"file_photo",true))
{
echo "Upload save sucessful.<BR>";
} else{
echo $upload->errors;
}
if ($upload->isPosted)
{
echo "<BR><BR><b>Some details about the upload:</B><BR>";
echo "Filename: ".$upload->getFileName("file_photo")."<BR>";
echo "Mime type: ".$upload->getFileMimeType("file_photo")."<BR>";
echo "File size: ".$upload->getFileSize("file_photo")."<BR>";
}
//--------- End Upload file
When I run this I get:
Upload class save error: unable to copy to /home/sites/site100/web/parties/images/town.gif
Upload class save error: unable to change permissions for: /home/sites/site100/web/parties/images/town.gif
Some details about the upload:
Filename: town.gif
Mime type: image/gif
File size: 28435
If anyone can help it would be great because I have spent so much time trying to figure it out. Thanks,
Chris