Target for PHP fwrite.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikefromBrighton
Forum Newbie
Posts: 2
Joined: Mon Mar 22, 2010 5:41 am

Target for PHP fwrite.

Post by mikefromBrighton »

Hi all,

I'm a bit of a newbie so here goes.

I've written a PHP application that reads a bunch of javascript array files, converts them into PHP arrays, loads them into a MySQL database and then, using PHP fwrite, creates new copies of the original javascript files.

All works fine and dandy, however, in the last step, when writing the new file copies, I want the user to be able to specify their local target directory location using a browse button as opposed to my hardcoding the target location with the script.

This sound simple, but I'm pulling my hair out here.

Can this be done???

Here's hoping.

Mike.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Target for PHP fwrite.

Post by Darhazer »

You want them to specify folder on the server or folder on computer.
In the first case you have to implement a file browser.
In the second, you cannot write JS on the client's computer. You can however set content-disposition: attachment HTTP header, and stream the JS file to the client.
mikefromBrighton
Forum Newbie
Posts: 2
Joined: Mon Mar 22, 2010 5:41 am

Re: Target for PHP fwrite.

Post by mikefromBrighton »

Thanks for the info Darhazer. This is basically an internal PHP program (maintaining some javascript arrays) using a browser as a user interface.

It all workks fine. I can already write the javascripts files ok. I can even specify their target folder from the browser by using an input field to capture the file path. My problem is that I want to determine the file path by browsing (similar to a file upload or download), instead of typing it in to the input field manually.

Hope this helps. Any assistance would be gratefully received.

Mike.
Post Reply