473,666 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with upload script and CHMOD's

3 New Member
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]
Nov 15 '08 #1
5 1883
Markus
6,050 Recognized Expert Expert
chmod the directory in which the images are stored.
Nov 15 '08 #2
petershaman
3 New Member
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 Recognized Expert Expert
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
petershaman
3 New Member
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 Recognized Expert Expert
[...] 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
4818
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 view the image. I've tried adding the following line: - chmod($uploadfile, 444); and also a few variations on it but to no avail.
43
2147
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 all the benefit of it? Thank U
7
5178
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 (($_FILES == "image/gif") || ($_FILES == "image/jpeg") && ($_FILES < 100000)) { if ($_FILES > 0) {
0
1777
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 = 2000000;
1
6107
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 have it in the script), and for now, I have the mode set to passive (although I'll give a choice later on when I actually implement the script). (I starred out the password here, it is in the file, though.) Here's the entire page (not much, just the...
3
1578
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 created, I think I set the value wrong but can get it to work original script <?php #include ("mymail.php"); $folder = $_POST; ?> <?php
2
2151
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 applet. Shop script works with : <input type="file" name="id"/> but not with applet's: <input type="file" name="SourceFile_1"/> I just cannot figure out how to fix this :(
5
3279
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 _uploadedfiles_xxxx) (php must be allowed to move uploaded files to this folder' - uploadedfiles_xxxx. I typed <?php chmod ('_uploadedfiles_xxxx',640); ?> into notepad and saved it as php in the uploaded_xxxx folder, when I went to test it, the error...
2
1616
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 give the chmod permissions in FTP through fileattributes propery to upload folder it will give the message as Status: Set permissions of '/admin/upload' to '777' Command: SITE CHMOD 777 upload Response: 500 'SITE CHMOD 777 upload': command not...
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8362
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.