venkir Posted July 12, 2006 Share Posted July 12, 2006 Hi All:This appears to be simple but I am stumped. I have searched through all the past post but to no avail. Basically:1. User clicks on a link and a php page is presented.2. User selects a local TEXT CSV file and clicks on the 'Upload File' button.3. Local file is sent to the web browser, where each line in the CSV file is read, processed, geocoded.4. A HTML table is formed to display the results of the geo coding.Everything works until this step.5. The user needs to now click on a button, type in the name for the output file (just the name ....)and the code should use the old directory path, append the output file name (as entered above), append the extension ".csv", open the file, write to it and close the file.I know all about fopen, fwrite and fclose. My specific questions are:1. How do I parse and retain the directory path of the original csv file so that I can save back to the same dir? $_FILES['userfile']['name'] does not have the dir path.2. In the php file which displays the result, how do I create another button that will enabe the user to traverse the local file system pick another location and type in the file name for the output?3. Lastly, since the results are displayed in the browser, the data has already been sent to the browser. If I save the results in an array in the php that processes the input, after the user clicks on this button, is the array available to me to then traverse and fwrite to the file?I guess fundamnetally I don't understand where the data resides since I don;t want it to go back to the web server just to save the ouput to a local file.Any help will be much appreciated!!!!-Venki Quote Link to comment https://forums.phpfreaks.com/topic/14350-saving-to-local-machine-how/ Share on other sites More sharing options...
legohead6 Posted July 12, 2006 Share Posted July 12, 2006 go to the code library forum and try the force download code! Quote Link to comment https://forums.phpfreaks.com/topic/14350-saving-to-local-machine-how/#findComment-56571 Share on other sites More sharing options...
venkir Posted July 12, 2006 Author Share Posted July 12, 2006 Thanks, Worked beautifully, wonder why the PHP Cookbook did not have any examples of this neither did the PHP and MySQL web development book. Anyway that justifies the existance of this forum. I have two additonal questions:To explain better, the current process is:1. getfile.php: Gets the original input file by using a form and a submit button, calls processfile.php2. File gets uploaded to web server successfully, invokes processfile.php which--moves the uploaded file, --process each record --Forms a table to display results in html--and creates two ouput files in the web server one with .xml and one with .csv extension3. I put the force download snippet of code before the html display in this php.But I don't see the results on the screen. When I click on the 'Submit' button in the getfile.php, it waits (processing ...) and then the pop-up window to save the first xml file comes up. File is saved successfully, but .......1. The second csv file is not downloaded.2. The html display does not show up now. Why and how to fix it?Thanks again for all the wonderful people out there.....This is one site that I am definitely going to contribute to.-Venki Quote Link to comment https://forums.phpfreaks.com/topic/14350-saving-to-local-machine-how/#findComment-56591 Share on other sites More sharing options...
Daniel0 Posted July 12, 2006 Share Posted July 12, 2006 As far as I understand you wan't to download two files in one request. That is unfortunately not possible, then you will need to put the files in an archive (e.g. zip). Quote Link to comment https://forums.phpfreaks.com/topic/14350-saving-to-local-machine-how/#findComment-56634 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.