scanbird Posted April 1, 2009 Share Posted April 1, 2009 Hi FolksI am facing 2 problems with files and their full path, or say otherwise, how to get them from where I want and to place them where I want.I use DevPHP to develop, test in Firefox and MSIE, and use XAMPP 1.6.8. for the Apache Server, PHP engine, MySQL, and PHPMyAdmin.1st problem : I need to get the user to select a text file on his computer (of which I know the structure), have it read by the code then insert the value in the database.If I hard code just a filename (same directory as application path) or a full pathname (C:\Folder\SubFolder\SubSubFolder\Filename.ext) everything works fine local. I am able to open the file with $line_array=file('filename.ext')The code is done with a <form method="post">, a <input type="file"> to be able to browse and a submit button.$_POST sees only the Filename.ext. If I ask realpath($_POST), I get 'C:\Folder\SubFolder' - the rest of the path is gone so no concatenation available to create a fullpath.Working with $_FILES gives also only Filename.ext, if I add 'enctype="multipart/form-data"' to the <form> tag, the process takes as long as 'go get yourself a coffee' with no real results.I know there is no code but I want to understand the concept first, code will follow if needed in the next input.2nd problem : the code outputs strings to create a Google Earth file. I want the user to tell the application where to put the file. I tried creating a link to the file <href src="project.kml"> but instead of asking me where I want to download the file, it evaluates it because it sees it as an XML file. (for those of you not familiar with Kml first line is <?xml ... ?>).Being local, the file is outputted in the application root directory as I have full permission on it. When going remote, I don't think I would like to create specific FTP access to save the file on the server and then d/l it. And I haven't found a browse button like the one to upload (input type="file").Any suggestions or hints to help me go on? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 1, 2009 Share Posted April 1, 2009 Check the file upload section in the manual:http://www.php.net/manual/en/features.file-upload.phpTo force someone to download a file, you can have PHP send several headers before the data. You'll need to change the link to a PHP script to do that. e.g.:download.php?f=file1.kmzhttp://www.google.com/search?hl=en&cli...amp;btnG=Search Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.