You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to upload some files along with other data to a PHP form. This is not a proper api, just a form post.
I have written code to post using both curl and httparty, the curl code works but the httparty code doesn't. All the data goes to the server but the server interprets the file data as strings and not file data. Here is the relevant snippet
# In order to test curl vs httparty using the exact same form. Curl requires an @ in front of the file name here we strip it outfilename=form_data[:listingImageFile].gsub('@','')putsfilename#File definitely existsputsFile.exist?(filename)form_data[:listingImageFile]=File.open(filename)form_data[:otherFile]=File.open(otherfile)#COOKIE has the authentication in itcookie_hash=HTTParty::CookieHash.newcookie_hash.add_cookies(COOKIE)response=HTTParty.post(URL,headers: {'Cookie'=>cookie_hash.to_cookie_string},multipart: true,follow_redirects: false,:debug_output=> $stdout,body: form_data)File.write("./test_results_party.html",response.body)putsresponse.code,response.message,response.headers.inspect
This code runs, it posts all the other form data but the files get interpreted as plain old strings
The text was updated successfully, but these errors were encountered:
I am trying to upload some files along with other data to a PHP form. This is not a proper api, just a form post.
I have written code to post using both curl and httparty, the curl code works but the httparty code doesn't. All the data goes to the server but the server interprets the file data as strings and not file data. Here is the relevant snippet
This code runs, it posts all the other form data but the files get interpreted as plain old strings
The text was updated successfully, but these errors were encountered: