Forum Moderators: coopster
I want to make a post-request from a programming language (in this case delphi) and save the data to a MySQL database.
The data I want to save is a single file. I don't need to know the name of the file nor the filetype so it's quite simple but how should my request look like and how do I get access to the file in php?
kind regards
Henrik
Instead of making the user enter information in a web form I want delphi to send the http-post to my server.
Then my php-script should catch the file submittet and save it in my MySQL db.
I know exactly what type, and name the file has so I only need to store the filedata (i guess that might make it a little easier).
My mainproblem is how the post-request should look like and how I access the filedata in php.
The rest I know how to do :)
Thanks again
Henrik
Assumption - Delphi is used to pass variables to PHP script which puts the data into MySQL.
$_POST [us4.php.net] is the array that contains form post variables so you'd need to pass your PHP script this array for it to appear if a form submitted the info. So if you have a "name" field the corresponding field in the array would need to look like $_POST["name"].
To access the data you need to use a SELECT (see MySQL website) [mysql.com] query (see PHP website) [us4.php.net] the MySQL db for the data. At that point you can do with it as you like.
POST /foo/index.php HTTP/1.1
Host: <A REF="http://www.zend.com:80/">www.zend.com:80</A>
Content-Type: application/x-www-form-urlencoded
Content-Length: 42
var1=filedata......blablablablablablablablablablablablablablablablablabla
Should I format it with URLencoding or something similar?
If not then what happens when the file has the content: "hey&var2=somedata"
wouldn't php take that as a second variable named var2?
I don't know if Delphi can do this encoding but i bet I can find a component that does the job.