?
Solved

PHP to access a .htaccess protected folder

Posted on 2003-03-23
6
Medium Priority
?
349 Views
Last Modified: 2008-03-03
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
Comment
Question by:idbeu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8189338
authorizing the Apache/IIS user to access this directory.
OR enable localhost access to it (the server is running locally)
0
 

Author Comment

by:idbeu
ID: 8190016
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
 
LVL 15

Accepted Solution

by:
VGR earned 300 total points
ID: 8190317
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:idbeu
ID: 8190352
HA! It worked. Thanks VGR, that was great advice.

The folder had 666 permissions, instead of 777.

:)
0
 
LVL 15

Expert Comment

by:VGR
ID: 8190419
classical :D
0
 
LVL 2

Expert Comment

by:bobsledbob
ID: 8192827

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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question