Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Upload issue on PHP Handler (Swift 3 / XCode 8) #45

Closed
aguel opened this issue Sep 21, 2016 · 4 comments
Closed

File Upload issue on PHP Handler (Swift 3 / XCode 8) #45

aguel opened this issue Sep 21, 2016 · 4 comments

Comments

@aguel
Copy link

aguel commented Sep 21, 2016

Im currently on XCode 8 with Swift 3 and i have a PHP file upload handler in the server side. Using the provided playground file, and basically just changing the POST URL to my PHP handler, upload doesnt work (file not reaching the server) but no error whatsoever. Fyi, i used another swift HTTP client (Swift 2.x version compatible) with the same PHP handler and it is working fine.

From playground:
let elonPhotoURL = Bundle.main.url(forResource: "elon", withExtension: "jpg")! let uploadResult = Just.post("**http://xxxx.com/uploader.php**", files:["elon": .url(elonPhotoURL, "image/jpeg")]) // <== that's it print(uploadResult.text ?? "")

Not sure if this log info will help?
"iSignature[10575:3106978] bool _WebTryThreadLock(bool), 0x7960e950: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now..."

@JustHTTP
Copy link
Collaborator

Does your server work with other kinds of uploads, with curl, for example? Does it receive the request despite the file missing?

Daniel Duan
Sent from my iPhone

On Sep 21, 2016, at 8:08 AM, aguel notifications@github.com wrote:

Im currently on XCode 8 with Swift 3 and i have a PHP file upload handler in the server side. Using the provided playground file, and basically just changing the POST URL to my PHP handler, upload doesnt work (file not reaching the server) but no error whatsoever.

From playground:
let elonPhotoURL = Bundle.main.url(forResource: "elon", withExtension: "jpg")!
let uploadResult = Just.post("http://xxxx.com/uploader.php", files:["elon": .url(elonPhotoURL, "image/jpeg")]) // <== that's it
print(uploadResult.text ?? "")


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@aguel
Copy link
Author

aguel commented Sep 21, 2016

Yes. As explained above, it works on other HTTP Client libraries. Basically the code uses POST, so i was thinking if this is a file upload, isnt this supposed to be PUT?

@dduan
Copy link
Owner

dduan commented Sep 21, 2016

@aguel from a technical point of view, there's no different between POST and PUT. But modern conventions give them different semantic meanings. Can you post uploadResult.text here?

@aguel
Copy link
Author

aguel commented Sep 22, 2016

Not an issue at all. I missed one parameter in the data section causing the problem.

@aguel aguel closed this as completed Sep 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants