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 8671793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:02:24+00:00 2026-06-12T19:02:24+00:00

I have a bunch of JavaScript files that I want to minify and then

  • 0

I have a bunch of JavaScript files that I want to minify and then cache it to a file. This file is saved to a location I provide as argument.

How can I make sure that location has is accessible from the web?

What I’ve tried so far:

$test = array
(
    '/Users/www/htdocs/test/nhecos/cache/test.js',
    '/Users/www/foo.js'
);
$host = 'http://localhost/';

foreach($test as $t) {
    $url = str_replace($_SERVER['DOCUMENT_ROOT'], $host, $t, $count);
    $perms = substr(sprintf('%o', fileperms($t)), -4);
    $p = substr($perms, -1);

    if ($count > 0 && $p >= 4) 
        print $url;
    else 
        throw new \Exception(sprintf("File %s not accessible from Web!", $t));
}

This works most of the times but fails if, for instance, that file is in a Virtual Host directory or in a linked folder. Is there any better way?

NOTE: my problem is ensuring that

“The files I generate are in a location that is known to the web
server and is mapped to a URL.”

  • 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-12T19:02:25+00:00Added an answer on June 12, 2026 at 7:02 pm

    To be accessible from the web is one thing, and to have “public read access” is another. You don’t need one to do the other.

    Typically “public read access” means OS-specific filesytem permissions. Accessible from the web means:

    1. It is in a directory that is known to a web server – that is, the file system location is mapped by the web server to a URL.

    2. The permissions for the file (and enclosing directory) are such that the web server process can read the file (for static files), and can execute the files (for scripts that are run from a handler that runs as the same user as the web server).

    So, in your case you want to make sure that:

    1. The script runs as the same user as the web server – this is normally the case, but in some situations your scripts may be running as a different system user.

    2. The files you generate are in a location that is known to the web server and is mapped to a URL.

    3. Finally, the permissions of the file you have generated (especially if the user that executes your script is not the same as the web server process), has the correct permissions based on the system’s layout.

    On most unix-like systems, the web server runs as www or apache. On debian its www-data.

    Generally, static files need octal permissions 644, that is owner to rw, and the rest to only read. In ls -l listing, this is -rw-r--r-- for files if the directory isn’t owned by the server process.

    For troubleshooting access permissions, the apache wiki has tips.

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

Sidebar

Related Questions

I have a bunch of JavaScript files that I would like to include in
I have an express app that has a bunch of static javascript files that
I have a bunch of checkboxes, and then this master checkbox that will uncheck,
I have a bunch of html files that come with my app and are
I'm wondering the best way to approach this. I have a JavaScript file in
I have a javascript slide show that creates the next slide dynamically and then
I have a javascript event handler in one of my SSI files that hides
I have a bunch of text files on server side with file names 0.txt,
Currently, I am using headjs to load my javascript files dynamically. I have bunch
Say, I've got an HTML file that I want to process using Javascript. For

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.