Submitting a file to a http url

Does anyone knows if I could submit an xml file to a php file for processing using the post command?

Basically, I have a php file that will process an incoming xml. It will read and extract the content of the xml, and update the data into the database.

For my unit tests on Windows, I achieve the task by using curl.exe. The command looks something like this curl.exe --digest -u accountName:password http://test/process.php -F theUploadFile =@filename.xml

Hence, I would like to find out if Eggplant would be able to achieve something like this through either the post command or do I have to use the shell command. If using the post command, would it be possible for you to provied me with an example?

I tried doing this: post file file.xml to url “http://test/process.php
but it did not achieve what I wanted. Thank you very much.

I think you’re close. Try this:

post URLencode( file "file.xml" ) to url "http://test/process.php"

You’ll need to have the quotes around the filename so that Eggplant doesn’t think you mean the “xml” property of the “file” object. Then you’ll want to put that whole chunk of data into the URLencode function so that it is formatted in a way that the server understands.

:cry: it doesnt work for me…is there anyway i can find out if the command was executed successfully? I tried printing the returns of the post command but it was empty. Is there a limit to the amount of data that can be posted? Is it the same as a HTML form post? if so, are there any other ways I can use to submit my data file to a URL, as I have a lot of data in the file to be submitted. please help… :cry:

thank you very much

Is your php processor expecting a file or the contents of a file? What the suggested solution sends is just the content of the specified file, but if your processor is expecting a file, then it may be trying to do things – like open a file – that just don’t work, since no file exists.

You should have your processor write out some log messages to a file saying that it’s been activated and what steps it’s performing. This will tell you whether the post is getting through to it or not.

hmm…i will have to check out the processor php then.

however, when i print out the “it” variable after the post command, it is empty. If my processor php prints out tons of stuff after I click on the “submit” button, will this info be returned to eggplant and goes into the “it” variable? if not, is there anyway eggplant can know if the execution is successful? Thanks again

The “it” variable will contain whatever is in the http response that your script provides. If you have a response page that puts up some custom HTML with the results of your script, then “it” should contain the raw html from that response.

Try this to see how it works:

post "q=drop" to URL ""
put it

If there is no http response, then you won’t be able to tell from the Eggplant side whether anything happened or not – we can only work with what the server gives us.

hey matt,
thanks for all the help. it appears that it may have something to do with the server security settings for the web.

I suspect that the reason why nothing was returned for my post command is that it is unable to access the php file. To support my findings, I did the following:
put url “http://test/test.php” into phpContent
put phpContent

And of course, nothing was returned, hence concluded my findings. Please correct me if I may be wrong.

I had also found out that the web server I am connecting to, has set Digest Access Authentication (which I cannot modify) ON for the web’s security. On PC, everytime I try to access that page, the windows authentication dialog comes out, and of course, in the eggplant case, this will not happen. So, I believe that this is not an Eggplant issue. Guess I will probably have to redirect my queries to Mac forum :D…thanks a lot once again.

However, if anyone has a solution to my problem, please let me know. Appreciate it. :slight_smile: