/    Sign up×
Community /Pin to ProfileBookmark

New to PHP scripting, can I do this…

Using fopen, can I create a file on the client-side, if so, how??

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@amazing_andr3May 11.2005 — You can create a cookie; that's a client-side file.
Copy linkTweet thisAlerts:
@wmac222authorMay 11.2005 — Thanks, that's a start, but I really want to create a javascript file on the client-side.
Copy linkTweet thisAlerts:
@amazing_andr3May 11.2005 — What do you mean 'create' ?

If you want PHP-generated javascript code, that can be done. It's exactly the same thing as PHP-generated HTML.

If you want to 'create' a file like this

fcreate('c:/windows/system32', 'evil-virus.js');

... you can't.
Copy linkTweet thisAlerts:
@NogDogMay 11.2005 — Basically, no. Possibly with a lot of contortions using a [url=http://us2.php.net/manual/en/wrappers.php]wrapper[/url] and configuring the client to act as an applicalble server for that type of wrapper, you [i]might[/i] be able to.

Essentially, it would be a gaping security hole if you could just write a file onto anybody's PC who visited your site.

Anyway, do you really need to write a javascript file to the client? I can't think of any reason you'd need to do so.
Copy linkTweet thisAlerts:
@wmac222authorMay 11.2005 — Let me explain my situation and perhaps you can see an alternative method to my madness...

I control 500+ printers spread over 12+ buildings. I have developed a web page where the user selects from a drop-down menu his/her building, then a 2nd menu lets user select the printer to be installed. They then selects if printer is to be their default printer.

I would like to create an simple *.js install printer file TO BE RUN ON THE CLIENT-SIDE (the big hang-up) on the fly, based on the incoming parameters similiar to:

++++++++++++++++++++++++++++++++++++++++++++++++++++

var WshNetwork = WScript.CreateObject("WScript.Network");

WshNetwork.AddWindowsPrinterConnection("MKEFSP02XEMSG102203");

WshNetwork.SetDefaultPrinter("MKEFSP02XEMSG102203");

WScript.echo("Printer installed successfully.");

++++++++++++++++++++++++++++++++++++++++++++++++++++

Suggestions greatly appreciated!!
Copy linkTweet thisAlerts:
@amazing_andr3May 11.2005 — Yea, you create the javascript code with PHP.

Just put this in the .htaccess

AddType application/x-httpd-php js

...and you can start using PHP in that file.
Copy linkTweet thisAlerts:
@wmac222authorMay 11.2005 — amazing_andr3..

thanks for the advice, but I just starting using PHP scripting about 6 hours ago -- so not sure what you are referring to!!
×

Success!

Help @wmac222 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...