Hi
I have a gorgeous flash image gallery, it would work perfectly fine but there's a small problem I can't upload anything thru it's upload script, since I'm getting an error 403. It's so because server sets by default CHMOD 600, whilst gallery needs to be set 644 to operate correctly.
In this upload php script there is a command which theoretically should change permissions for uploaded files, but it's not doing the job, there's obviously some bug over there, and here's my question, could you be so kind and take a glimpse at this code, and tell me how to shrink it? Cheers
[PHP]
/**
* Upload file
*
*/
function uploadAction()
{
$this->_setNoRender() ;
if (!isset($_FILES['Filedata'])) {
header("HTTP/1.1 500 Internal Server Error");
echo "Error. File not found";
return;
}
$imageData = $_FILES['Filedata'];
if (!ivFilepath::m atchSuffix($ima geData['name'], $this->conf->get('/config/settings/allowedExtentio nsArr'))) {
header("HTTP/1.1 403 Forbidden");
echo "Error. Wrong extention";
} else {
$fullpath = ROOT_DIR . $this->path . $imageData['name'];
$result = @move_uploaded_ file($imageData['tmp_name'], $fullpath);
if ($result) {
chmod($fullpath , 0777);
$FSItem = ivFSItem::creat e($fullpath);
$FSItem->generateThumb( );
$filename = ROOT_DIR . $this->path . 'folderdata.xml ';
if (is_file($filen ame)) {
$file = file_get_conten ts($filename);
$file = preg_replace('/\s*fileCount=\" \d*\"\s*/i', ' ', $file);
$result = @file_put_conte nts($filename, $file);
}
echo "File {$imageData['name']} succesfully uploaded";
} else {
header("HTTP/1.1 500 Internal Server Error");
echo "Error. File {$imageData['name']} wasn't uploaded";
}
}
}[/PHP]
I have a gorgeous flash image gallery, it would work perfectly fine but there's a small problem I can't upload anything thru it's upload script, since I'm getting an error 403. It's so because server sets by default CHMOD 600, whilst gallery needs to be set 644 to operate correctly.
In this upload php script there is a command which theoretically should change permissions for uploaded files, but it's not doing the job, there's obviously some bug over there, and here's my question, could you be so kind and take a glimpse at this code, and tell me how to shrink it? Cheers
[PHP]
/**
* Upload file
*
*/
function uploadAction()
{
$this->_setNoRender() ;
if (!isset($_FILES['Filedata'])) {
header("HTTP/1.1 500 Internal Server Error");
echo "Error. File not found";
return;
}
$imageData = $_FILES['Filedata'];
if (!ivFilepath::m atchSuffix($ima geData['name'], $this->conf->get('/config/settings/allowedExtentio nsArr'))) {
header("HTTP/1.1 403 Forbidden");
echo "Error. Wrong extention";
} else {
$fullpath = ROOT_DIR . $this->path . $imageData['name'];
$result = @move_uploaded_ file($imageData['tmp_name'], $fullpath);
if ($result) {
chmod($fullpath , 0777);
$FSItem = ivFSItem::creat e($fullpath);
$FSItem->generateThumb( );
$filename = ROOT_DIR . $this->path . 'folderdata.xml ';
if (is_file($filen ame)) {
$file = file_get_conten ts($filename);
$file = preg_replace('/\s*fileCount=\" \d*\"\s*/i', ' ', $file);
$result = @file_put_conte nts($filename, $file);
}
echo "File {$imageData['name']} succesfully uploaded";
} else {
header("HTTP/1.1 500 Internal Server Error");
echo "Error. File {$imageData['name']} wasn't uploaded";
}
}
}[/PHP]
Comment