Problem with upload script and CHMOD's | Newbie | | Join Date: Nov 2008
Posts: 3
| | |
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::matchSuffix($imageData['name'], $this->conf->get('/config/settings/allowedExtentionsArr'))) {
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::create($fullpath);
$FSItem->generateThumb();
$filename = ROOT_DIR . $this->path . 'folderdata.xml';
if (is_file($filename)) {
$file = file_get_contents($filename);
$file = preg_replace('/\s*fileCount=\"\d*\"\s*/i', ' ', $file);
$result = @file_put_contents($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]
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,948
| | | re: Problem with upload script and CHMOD's
chmod the directory in which the images are stored.
| | Newbie | | Join Date: Nov 2008
Posts: 3
| | | re: Problem with upload script and CHMOD's Quote:
Originally Posted by Markus chmod the directory in which the images are stored. It's 777, I'm sure, that this code needs some modification, I've had similar issue with other upload script, in which I solved the problem, but this one seems to be harder.
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,948
| | | re: Problem with upload script and CHMOD's Quote:
Originally Posted by petershaman It's 777, I'm sure, that this code needs some modification, I've had similar issue with other upload script, in which I solved the problem, but this one seems to be harder. So is it when you try and view the image that you get the access forbidden error? After you upload the image, what is the permission on the image?
| | Newbie | | Join Date: Nov 2008
Posts: 3
| | | re: Problem with upload script and CHMOD's
It's a bit more complicated, since it's a flash gallery, and upload is based on flash too.
When trying to upload script detects, that file has 600 permissions, and stopping uploading, so nothing can be done, but in fact yes, when I'm using normal (only php based upload, ot thru ftp), permissions are the same - 600 not like it should be 644.
|  | Moderator | | Join Date: Nov 2006 Location: Iceland
Posts: 3,752
| | | re: Problem with upload script and CHMOD's Quote:
Originally Posted by petershaman [...] since I'm getting an error 403. [...] Looking over your code, wouldn't that be caused by line #15?
If so, then why do you assume this is a permission error?
Seems like your code is rejecting the file extension to me.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|