• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 352
  • Last Modified:

PHP to access a .htaccess protected folder

I made a script that uses the copy() function to upload a file to a directory on the server. The script works just fine when I leave the directory unprotected. However, I have protected the directory with .htpasswd and .htaccess so that the files that are uploaded are not public domain. This makes the PHP script return an error in the browser:

Warning: Unable to create '/home/.1qaz/vault/files.url.com/vault/DSCF0025.JPG': Permission denied in /home/.1qaz/vault/files.url.com/index.php on line 11

If I understand this correctly, it means the PHP script has no authority to get around the .htaccess authentication. I would like a way to pass authentication to the directory, or get around the whole authentication process altogether.

What would you recommend?
0
idbeu
Asked:
idbeu
  • 3
  • 2
1 Solution
 
VGRCommented:
authorizing the Apache/IIS user to access this directory.
OR enable localhost access to it (the server is running locally)
0
 
idbeuAuthor Commented:
The server isn't running locally. I simply have an account with a provider.

Is this something I can request of the administrators? Would they be willing? :) I suppose I can ask.

Thanks! Any other recomendations that I can do without administration help?
0
 
VGRCommented:
ho, then it's for sure (99%) a problem of access right for you

sure : ask the provider for the cause of the error, as I think you're not doing anything forbidden

(except if YOU created the directory you try to write in, using FTP for example. Then you should set appropriate permisisons like 777)
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
idbeuAuthor Commented:
HA! It worked. Thanks VGR, that was great advice.

The folder had 666 permissions, instead of 777.

:)
0
 
VGRCommented:
classical :D
0
 
bobsledbobCommented:

For those of you keeping score at home, please note that the copy() function DOES NOT bother to take into account any settings you have in .htaccess .  This is applicable to ANY file manipulating function in PHP or otherwise (fopen, fwrite, file, etc).

The reason?  .htaccess is an APACHE ONLY thing.  It is NOT a file control mechanism of the operating system.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now