That’s what I’m doing. I explained it to see the whole picture, that I used the string format first, which worked fine, but since I have to upload pictures, executables etc. I must use withFileToUpload, and I do use it, but it doesn’t work… The main problem for me right now is I have to use that auth string at the end of the url, wihthout it I can’t access the webscript, and when I’m using withFileToUpload, it works like I didn’t put it there, so won’t let me use it.
P.S.: of course I check if the upload was successful (but when the server returns with an auth error, obviously it was not successful)
I had written code for uploading the files using curl and I know for sure I wasn’t sending the MIME type. I don’t have the code now. I will get back to you after going through the code. Don’t know how much useful it would be. Lets hope for the best.
I had read your post and got confused, i thought you were using separate code for text and binary files. :oops:
Jules:
Well maybe there’s some kind of webserver configuration problem. However, why does the url including the GET parameter work with simple withParameters (already a mixture of GET and POST) but with withFileToUpload? (btw the server is Alfresco, and it just needs that ticket at the end of the url as a GET parameter, otherwise it just won’t let me use the webscript)
vishvesh:
It won’t work without MIME since the function takes 3 parameters. But makes sense, because I checked the webscript, and it contains a guessMimetype function called with the filename, so theoretically it’s not necessary to be provided.
I would like to see that cURL code if it’s not a big problem to find thanks!
I know very little about webservers, and nothing at all about alfresco, but they do check their input and reject things they don’t like. I had problems myself uploading files when the mime type didn’t match the file.
I found the code. Send me your email id. I will mail you the code. My server was a asp.net page which used to accept data. May be the server was handling all the stuff related to MIME type.
I can only contribute a trivial footnote. If the content to send is not too long a string, it can be easier to put it in a query string as part of the URL, like this:
Of course that’s probably not sufficient for your needs, but it avoids an HTTP POST for simpler data items, and JavaScript has simple methods for extracting the query string.
ok I found out what is my problem (I already assumed this could have happened but now I’m sure about it). I printed out all the parameters with a php file, and found out that for some reason when I used withFileToUpload, the GET parameter did not disappear, but has been sent as a POST parameter… Jules, could you take a look at the code in juce? maybe it would be easy to fix
There’s nothing to fix - it’s doing exactly what it’s supposed to! The URL class will either send its parameters through a GET or a POST, but not as a crazy mixture of both!