Access Denied For One Script But Not The Other
Moderator: General Moderators
Access Denied For One Script But Not The Other
I am working on a website that allows users to upload images to their folder on the ftp server. I have several pages of the site that allows this uploading of different images, and on the first page I finished, everything works just fine. I copied the code over to the second page and kept everything the same but I get access denied. The scripts are being included into the same php file, they are located in the same directory and their destination directory are that same.
This is happening on my windows dev machine. The user folders were created with ftp_mkdir (or something similar to that) in php. I've checked the file permissions through the explorer and everything seems to be alright. Any ideas?
This is happening on my windows dev machine. The user folders were created with ftp_mkdir (or something similar to that) in php. I've checked the file permissions through the explorer and everything seems to be alright. Any ideas?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Access Denied For One Script But Not The Other
Are you referencing from the root or local paths?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Access Denied For One Script But Not The Other
Are the scripts literally identical?
Re: Access Denied For One Script But Not The Other
yes sir they are. Copied and pasted.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Access Denied For One Script But Not The Other
Lots of questions to answer...how lovely
If I were you i'd double check the destination path you're using to upload the images - in most cases this is the problem.
If I were you i'd double check the destination path you're using to upload the images - in most cases this is the problem.
Re: Access Denied For One Script But Not The Other
the paths are the same.
I first attempted different paths because, well, if I didn't it would be pointless to have the second upload script. But when that didn't work, I thought it might have something to do with the fact that I created the dirs through the ftp command because I had never used it before. So, I switched the paths to the exact same thing as the other script that works (copy and paste) and I get the same error.
[edit]
I have created a function in a separate functions file that I use for both uploads. I pass the file name, the desctination dir, and, and another variable if I wish to rename the file upon upload. Same function. Calling the function with identical code and it doesn't work.
I first attempted different paths because, well, if I didn't it would be pointless to have the second upload script. But when that didn't work, I thought it might have something to do with the fact that I created the dirs through the ftp command because I had never used it before. So, I switched the paths to the exact same thing as the other script that works (copy and paste) and I get the same error.
[edit]
I have created a function in a separate functions file that I use for both uploads. I pass the file name, the desctination dir, and, and another variable if I wish to rename the file upon upload. Same function. Calling the function with identical code and it doesn't work.
Re: Access Denied For One Script But Not The Other
Heres the code:
This is the calling of the function from the second (non-working) script.
This is the calling of the function from the first (working) script.
And finally, this is the code for the function that uploads the file.
This is the calling of the function from the second (non-working) script.
Code: Select all
$target=$_SESSION['name']."/images/";
uploadImage($target,'photo1');
Code: Select all
$target=$_SESSION['name']."/images/";
uploadImage($target,'logo','title_image');
Code: Select all
function uploadImage($target,$file,$name=-1)
{
switch($_FILES[$file]['type'])
{
case "image/png":
if($name==-1)
{
$filename=$_FILES['{$file}']['name'];
$target.=$filename;
}else{
$filename=$name.".png";
$target.=$filename;
}
//etc
}
if(move_uploaded_file($_FILES[$file]['tmp_name'],$target))
{
//do stuff
}
}
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Access Denied For One Script But Not The Other
Where's session_start()?
Re: Access Denied For One Script But Not The Other
In another file that includes both the func file and both script files.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Access Denied For One Script But Not The Other
uploadImage requires 3 parameters no?
Line 3 on "not working" script only supplies 2 parameters.
Line 3 on "not working" script only supplies 2 parameters.
Re: Access Denied For One Script But Not The Other
The third parameter is optional.aceconcepts wrote:uploadImage requires 3 parameters no?
Line 3 on "not working" script only supplies 2 parameters.
The exact error I get is..
Warning: move_upload_file(watson516/images/)[function...]: failed to open stream: Permission denied in C:\... on line 73
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Access Denied For One Script But Not The Other
Well, this is as it states, a permission error.
Re: Access Denied For One Script But Not The Other
Off topic a bit, but what happens when I answer the phone in the middle of using the page for half an hour, the session expires and $_SESSION['name'] is no longer available?
Re: Access Denied For One Script But Not The Other
If the session expires, they have to relogin.onion2k wrote:Off topic a bit, but what happens when I answer the phone in the middle of using the page for half an hour, the session expires and $_SESSION['name'] is no longer available?