I needed to be able to upload images in an app I’m making and figured that if I needed this functionality chances are there is at least one other person that might as well so I have posted it in the code exchange.
It’s all very simple and basic but if it saves someone 5 minutes then I figured it was worth it. [import]uid: 5833 topic_id: 5062 reply_id: 305062[/import]
hey thanks for the contribution, I wouldn’t have thought to do this with FTP. I would have written PHP or Python on the server than returns images in response to GET requests, but your way is simpler. [import]uid: 12108 topic_id: 5062 reply_id: 16613[/import]
That’s exactly what I was going to do (as that’s what I’ve been doing for text) before realising FTP might be possible and it turned out to be pretty easy. [import]uid: 5833 topic_id: 5062 reply_id: 16655[/import]
If you upload a file with the same name as an existing file it should overwrite it. However you may need to change permissions on your server. Is this what you meant? [import]uid: 5833 topic_id: 5062 reply_id: 39314[/import]
All my code does is allow you to upload a file, protection of that file would be beyond the scope of it.
For ideas though, you could maybe upload it to a unique url that you could then give to that user, or put it in a folder and use basic authentication to protect it, or I’m sure other things. [import]uid: 5833 topic_id: 5062 reply_id: 44973[/import]
@peach - I’ll never get used to your praise. I’m still not even sure if you are using “BAFTA” as an insult or compliment
@hiphopsded - I can’t remember exactly as I haven’t used the FTP stuff in a while, but you should be able to choose the name of the remote file for when you upload it, if not you could just rename the local file before uploading it. As for the name itself you could maybe use the current os.time() and maybe prefix it with a unique code specific for the user.
As for basic authentication - http://en.wikipedia.org/wiki/Basic_access_authentication - it is fairly trivial to do in from the end of the app ( loggin in ) as I have done it for a client app, however I am not a web developer so have never had to do it from the server end. [import]uid: 5833 topic_id: 5062 reply_id: 45198[/import]
Basically what I am wanting to do is allow a user to upload “settings1.db” located in the documents directory and have them download it to replace their current one if they want.
I get renaming the file to the current time, but I don’t know how I would call for that specific file again when it needs to be downloaded
Thanks [import]uid: 14940 topic_id: 5062 reply_id: 45213[/import]
You could either store the filename off somewhere on disk, or give the user a code they can enter which has been linked on your server to the unique url. [import]uid: 5833 topic_id: 5062 reply_id: 45222[/import]