Jump to content

Using fwrite() to create file in scripts directory


louisstephens
 Share

Recommended Posts

Just a quick question, I have a function in my ready.php file that creates a new js file inside the "scripts" folder (under templates). Everything is working as expected, however, is it possible for the url to look like www.domain.com/scripts/generated.js ?

 

Currently, the only way I can access it is via www.domain.com/site/templates/scripts/generated.js. Or is there a better place I should be putting these scripts ? I I am trying to use the scripts elsewhere (not on the processwire install).

Link to comment
Share on other sites

1 hour ago, louisstephens said:

Or is there a better place I should be putting these scripts ? I I am trying to use the scripts elsewhere (not on the processwire install).

I there's maybe two things to consider

  1. Can your fwrite() access the location you want to write to?
  2. The location of the js script needs to be accessible (readable) to the world so that browsers can serve it..

If the js script are for external use (i.e. external to PW), maybe you want to keep it clean and add them to the file system of whatever app you are using them for.

Just my lazy 2p on a lazy Friday afternoon..:)

Link to comment
Share on other sites

56 minutes ago, kongondo said:

The location of the js script needs to be accessible (readable) to the world so that browsers can server it..

I guess what kongondo is talking about is that PW is blocking access to /scripts folder via its .htaccess so you would have to modify it to grant access to this folder to everybody. Or you just leave the script in a web-accessible folder like inside /site/templates

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...