Can Google Map API GXml parse .kmz files directly? if not how is the best way to convert .kmz file to .kml? The .kmz file is stored on database and PHP code is used to retrieve it.
I'm pretty sure that there's no way to unpack zipped data with Javascript, which you'd have to do before passing the data to GXml.parse.
GGeoXml can handle KMZ files. It does it by passing the URL to a Google server which unzips the data and parses it there, then returns the individual overlay objects to the Javascript client.
Since you're reading the data with PHP, you might consider unzipping it in your PHP script, and serving the unzipped data to the client. You may need to do some work to your PHP configuration in order to enable the PHP Zip File functions.
Related
So I've been working for around two months with cURL post requests via php and when it's about sending files I've been using the .txt extension files and my questions are:
Is it better (or even possible) to send the data as a .xml file?
And if yes, curl_file_create() function also works with .xml files or is there another way to accomplish this?
Is it better to send the data as a .xml file?
Yes. No. Maybe.
It depends on what the server expects you to send.
It depends on what format is most suitable for expressing the information you are sending.
JPEG might be the best format!
curl_file_create() function also works with .xml files
It deals with files. Nowhere does it say it only deals with particular types of file.
Is there a way to have PHP capture a file being uploaded (POSTed) such that PHP can manipulate the file before it is ever written to disk?
Example application: A form where a user can upload a file to my web application, and my application encrypts it with PGP before it ever is written to disk.
Uploaded files are stored as temporary files by PHP until you manipulate them (see http://www.php.net/manual/en/features.file-upload.post-method.php). You can use INI settings to control where the files are stored, but you can't really intercept them before they are written to a temp location.
You can certainly PGP encrypt them before you move the file into its final location.
Depending on the library you use on the front end, it should be possible to base64 encode the file and then send it as regular post data to PHP, thus avoiding writing the file to disk. There would be added overhead, of course, and you will end up sending more data over the wire this way. But, it can work (I've done it, though scrapped the idea due to the additional bandwidth usage).
Your backend will need to properly decode the data and handle it from there. I would recommend chunking the data if you do it this way so you can retry failed portions without having to upload the entire file again.
I have a WebService that works that way:
I send a file through ftp into a specific folder in my remote server;
I call a web service in that same server so that the file name and path can be recorded in the data base. Only this way the system will know of the file existence.
I do it that way because I do not know how to make a web service that can receive a file by HTTP POST directly.
The server works under PHP & MySQL.
The client that sends the file and register it is made in Delphi. I use Indy now.
In the future I intend to make it full web but my client is still addicted to windows.
So, can I make a rest web service that receives a pdf file and also receive data about this file, like "from", "to", "description"...? How?
In order to upload a file, you must perform a POST call to your WebService. (You can also perform a PUT operation, but that's not covered in this answer).
The php part:
In php, you use the $_FILES associative array, which contains the items uploaded to the script using the mentioned POST method.
Once you accept the file, you use the move_uploaded_file function to save the file in your server disk, and then you can read the file from there and post it to a database or any other operation you want to perform.
I recommend you to read the referenced articles in the handling file uploads php manual entry.
You can also find a working example on the php file upload w3schools article.
The Delphi part
There are various libraries that allow you to perform HTTP operations from Delphi. My preferred one is Indy Sockets, and you'll find a great number of questions (and answers) here on StackOverflow, for example: Http Post with indy which includes a flie attachment.
I'm thinking of using XML for storing users content on my web app. I am a php newbie and don't know much about how I would do this.
The content is private to the user, not shared public or for passwords or anything. So I was wondering how I can create and edit xml files on the backend part of the server, privately accessed by PHP like what it does with mySQL.
My questions are: 1) Is it possible 2) If so, how would I do it using php etc.
Put all xml files in a folder that is not accessible via the web, so outside of your document root. Alternatively, you can use .htaccess to restrict access to that folder.
For reading and writing those xml files from your directory, you can use simplexml. You don't need anything else despite pure php and some xml processing.
This should get you started ;).
Theoretically it is possible. by making your xml in php files format which output xml formatted tags after PHP authentication. The PHP files will be created dynamically using PHP filesystem functions and will be modified also, for each users in a specified folder(s) for your users.
I'm wanting to generate a dynamic zip/gzip file using php (user clicks button/link/whatever, and sends file to download) which contains a folder structure that may or may not have files (could be blank or contain data) in all the folders.
The aim is to be able to unzip this file and have a folder/file structure ready to go.
I believe I am familiar with everything involved, except how to generate the file without creating the files on my server locally, then zipping them and sending for download. This seems to include 'writing the files to the server' as a sort of middle man that I would just assume bypass if possible.
I would like to assume this is as easy as sending raw data to the browser with a zip/gzip header, but I haven't had much luck finding any information on this.
Any pointers in the right direction would be most helpful.
You can do that with the ZipArchive class. Have a look at function such as ZipArchive::addFromString() which will allow you to add files to the archive without actually saving it them to disk first.