Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: PHP Question  (Read 1150 times)

0 Members and 1 Guest are viewing this topic.

mit

PHP Question
« on: March 02, 2008, 11:06:49 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
I somehow doubt anyone here'll know, but I'm thinking about advanced-ish file upload systems.

My point is, when storing a file it presents obvious problems to just upload it. Normally we rename it to stop scripts running and so on. I want to create a script that handles the uploads in a way that seems to the user that no change whatsoever has happened to the file.

I'm assuming I could do this by visiting a downloading script, which reads the file byte by byte and sends each to the browser - but I'm thinking this will inevitably lead to errors, probably script timeouts, and if done incorrectly memory overloads.

So I guess my question is - is there a better way to do this? is the feeding it through a running php script a terrible idea? is there some simple way to make a folder 'safe' to upload and download any kind of file to using .htaccess?


Also, and hints or tips on ways of doing image previews of multiple sizes would be appreciated. I'm assuming the best way is by using the GD library to create them, and store them in a folder with a size limit, deleting the oldest ones when necessary - so images could be cached by browsers without having to modify headers, but it doesn't take insane amounts of space.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games

alirazaq

Re: PHP Question
« Reply #1 on: March 02, 2008, 11:20:30 pm »
you want it so when the file is uploaded it is renamed but all the user gets is:

http://domain.com/?file=oaiwfyhob

but it still leads to the same file? Please clarify because I do not understand what you mean.
Logged
Re: PHP Question
« Reply #2 on: March 02, 2008, 11:53:13 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Quote
I'm assuming I could do this by visiting a downloading script, which reads the file byte by byte and sends each to the browser - but I'm thinking this will inevitably lead to errors, probably script timeouts, and if done incorrectly memory overloads.
I actually use a system like this, whenever a user accesses their space (http://members.xxx.binaryphoenix.com), it accesses a download script which will copy the data from the file (which is stored in a secure passworded folder, and has been renamed to prevent script execution) and into the output stream (it modifys a few headers as well to allow the end-client to know what its downloading). I personally have never seen any problems with it, I've used it many times to emit very large file (50mb+), without error. The script timeout should never come into effect doing something like this (the script timeout is something like 2000ms), you should be more than able to copy and emit the data within that time limit. Sending the data internally is dealt with by the socket and won't result in a timeout. Although your right about memory overloads, but only if you do something stupid like read the whole thing into a buffer before emitting it, rather than doing it chunk by chunk.
Logged

mit

Re: PHP Question
« Reply #3 on: March 03, 2008, 09:39:23 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
Thanks Infinitus, really helpful to know it worked for you. I wasn't sure about whether it would work at all, so thanks.


@Ali, that's not really what I want at all - more to have it so that the user downloading the file doesn't realise that the file was ever renamed, but Infinitus has basically answered my question now anyway.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.689 seconds with 45 queries.