homer.favenir Posted June 4, 2008 Share Posted June 4, 2008 hi to all, i made my script working very fine and it reads a file and write it down to a new txt file, but the problem is when my someone uses the program it didnt save in their directory, but in my directory, even if he specifies the location or i hardcoded the location. it always saves in my directory. how can i make it saves to their directory. my script: <html> <head> <title></title> </head> <body> <?php function compare_write($str1, $str2) { $count = 0; $dir = 'C:\Documents and Settings\All Users\Desktop\portfoliocompare\\'; $file = $_POST['newFile']; $file = $dir . $file . ".txt"; if(file_exists($file)) {?> <table border=0> <tr> <td> <h2><font color="#FF0000">Warning! </font>File Already Exist. Pls Rename</h2> </td> </tr> </table> <?php }else{ $file = trim($file); $file = fopen($file, 'w'); $diff = array_diff($str1, $str2); foreach($diff as $key => $line) { echo $line . "<br>"; fwrite($file, $line); $count++; } echo $count . " " . "Records found"; } } ?> </body> </html> please advice. thanks Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/ Share on other sites More sharing options...
homer.favenir Posted June 4, 2008 Author Share Posted June 4, 2008 BTW im the server, and when my officemate is the server it saves to his directory. is there a way that only 1 server and many client and the client can save in their directory. thanks Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/#findComment-557223 Share on other sites More sharing options...
GingerRobot Posted June 4, 2008 Share Posted June 4, 2008 You want to save it to the client's machine? You'll have to offer it as a download. Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/#findComment-557228 Share on other sites More sharing options...
homer.favenir Posted June 4, 2008 Author Share Posted June 4, 2008 the text file should be save in the client's directory. but it saves in the server's directory. thanks Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/#findComment-557258 Share on other sites More sharing options...
dmccabe Posted June 4, 2008 Share Posted June 4, 2008 You want to save it to the client's machine? You'll have to offer it as a download. As GingerRobot said, you need to make offer the file as a download. PHP is a server side language so cannot do anything to a client machine. Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/#findComment-557264 Share on other sites More sharing options...
prcollin Posted June 4, 2008 Share Posted June 4, 2008 You want to save it to the client's machine? You'll have to offer it as a download. As GingerRobot said, you need to make offer the file as a download. PHP is a server side language so cannot do anything to a client machine. wait are you trying to get it to dl to his computer or to a directory on the web from the looks its a directory on a computer, in that case yeah what everyone else said otherwise we have other solutions for web Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/#findComment-557284 Share on other sites More sharing options...
prcollin Posted June 4, 2008 Share Posted June 4, 2008 or make a password protected shared folder on network to route the files to? never done it but maybe so that you can access from all computers but only the one with password can read it Link to comment https://forums.phpfreaks.com/topic/108658-solved-fwrite-save-file-in-my-folder-how-to-change-location/#findComment-557286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.