473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Problem with upload script and CHMOD's

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]
Nov 15 '08 #1
5 1874
Markus
6,050 Expert 4TB
chmod the directory in which the images are stored.
Nov 15 '08 #2
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.
Nov 15 '08 #3
Markus
6,050 Expert 4TB
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?
Nov 15 '08 #4
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.
Nov 15 '08 #5
Atli
5,058 Expert 4TB
[...] 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.
Nov 16 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ian N | last post by:
Hi i'm having a problem with file permissions of upload, they appear to be being set to only readable by the administrator, so anyone browsing the site gets a 403 forbidden error when they try and...
43
by: balakrishnan.dinesh | last post by:
Hi all, Im working in javascript, I want to use Ajax in javcascript, Can u tel me how to use ajax in javascript, whether i have to include any code as like to include *css or *.js file, what are...
7
by: hadge | last post by:
Hi im trying to get images to upload into a directory on my server but i cannot get them to upload as chmod 755 so that they are viewable can anyone help? <?php include"connftp.php"; ?> <? if...
0
by: foekall | last post by:
I used this script and test on my hosting. Evertimes appear "change permission to 777 failed. ". So, how to solve this error. Please kindly check for me and teach me. <?php $MAX_SIZE =...
1
by: PehJota | last post by:
I'm kinda new to PHP, and I'm trying to make a simple FTP upload script. It successfully connects to the server and logs in, but it can't upload. The transfer mode I use normally is ASCII (like I...
3
by: webandwe | last post by:
Hi, I got form that let you state a folder name, on sumbit thw script creates the folder with the name you stated, the problem is I want it to upload the php file "view.php" when the folder is...
2
by: Event Horizon | last post by:
Hi, I'm trying to add an simple upload applet to shopping cart script. My new applet form sends all needed post fields ( quantity, product, etc... ) but the "file" post field is hardcoded in...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
2
by: swethak | last post by:
Hi, i wrote a code to upload a image.In my local it works fine. When i place this code in website through FTP. In that it will not works. i am giving the upload path ../upload . When i try to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.