Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:23:01+00:00 2026-06-03T16:23:01+00:00

I will try to explain this as well as I possibly can. I’m developing

  • 0

I will try to explain this as well as I possibly can. I’m developing a member-driven website where members can upload files to sell them (where they own the rights to these files).

PREMISE 1: I wanted to ensure that each member’s folder could not be accessed directly and could only be reached through a link from the site itself.

This link is only generated in the member’s area of the person who has bought it (for downloading the file more than once…and member profiles don’t allow for linking to these folders either).

So every time a member joins they are given a file into which a .htaccess is automatically created.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
RewriteRule .* - [F]

PREMISE 2: When a user uploads a file, the last step in the process is to make sure that file has in fact uploaded.

$uploadFullPath = 'http://www.domain.com/userfiles/'.$_SESSION['uniqueKey'].'/'.$_SESSION['userNumber'].'-'.$_SESSION['latestUpload'].'.'.$_SESSION['latestExt'];
 if(fopen($uploadFullPath,"r")!==0){
  // update member usages
  $query = "UPDATE memberUsage SET usageLicenses=usageLicenses+1 WHERE memberNumber=".$_SESSION['userNumber'];
  mysql_query($query) or die(reportError('Unable to increment licenses used'));
  echo 'Your file has been successfully updated. You can view your listing within <a href="/user-area/">Your Dashboard</a>';
}
else{
 echo 'There seems to have been a problem uploading your file. Please <a href="/user-area/">go back</a> and try again from your \'incomplete listings\' page. Upload Path Provided: <a href="' . $uploadFullPath .'">' . $uploadFullPath . '</a>';
}

For clarity the reportError() function is just a preloaded function that churns out the mysql_error() and mysql_errno() any time an error needs reporting, to save typing it each time.

Also where above I have used fopen() I have also tried to test for the file’s existence using is_file() and file_exists().

The Problem
With the above htaccess restrictions fopen(), is_file() and file_exists() all fail to find the file, even though when the generated $uploadFullPath is clicked it works.

However if I remove the htaccess restriction the above functions work, but equally the files can be accessed directly without buying or going through the website first.

How do I get both of these conditions to run simultaneously please? I’m not sure if it’s just htaccess, just my file detection method or a combination of both.

My thanks in advance for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:23:04+00:00Added an answer on June 3, 2026 at 4:23 pm

    If possible, just use your local filesystem instead of the http://-wrapper.

    So, for example, if your PHP file is /var/www/kirby/myfile.php and your uploads are stored in (again, an example) /var/www/kirby/useruploads/cooluserone/test.jpg (assuming test.jpg as an uploaded file).

    In this case, you could either use the relative path file_exists("useruploads/cooluserone/test.jpg") or the complete path file_exists("/var/www/kirby/useruploads/cooluserone/test.jpg").

    Both of this would return true.

    You have to make sure you have read access on the folder / files though, which you probably already have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going to try to explain this best I can I will provide more
I will try to explain this the best way I can, but feel free
I will try and explain this the best way I can. I have a
I will to try to explain this as best as I can. I have
I hope I can explain this well, if I don't I'll try again. I
sorry for asking this dumb question i will try to explain as good as
Okay, this scenario is a little complicated, but I will try to explain it
I will try to make this as clear as I can, but if you
OK, this is impossible, but I will try to explain the situation here. Let's
I will try to explain as well as possible what I'm trying to do.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.