Thanks,

Bastien

> On Sep 27, 2013, at 12:56 AM, Mariusz Drozdowski <scheme...@wp.pl> wrote:
> 
> Hi all php experts,
> 
> I would like to ask you all a question, I hope this is the right place
> to ask it.
> 
> I'm writing a PHP extension now in c/c++. User uploads a file (could be POST
> or PUT method, but I can limit it to POST only). I need to capture the
> file data while being
> uploaded, without writing it to disk on the server. I need to process
> the data and (maybe,
> depending on a situation) send it somewhere else or save it to disk.
> Of course I know, that I can process the file
> after it has been uploaded (saved on disk on the server), but I would
> like to avoid it.
> I also need to do something opposite: I need to generate a file "on the
> fly" and send it
> to the user. All metadata of the generated file is known beforehand
> (e.g. size, name).
> 
> I've been searching around for some time now and I could not find
> anything even close to the solution.
> Is there any example(s) or existing PHP extension that do(es) something
> like this (at least something simmilar) ?
> If you could give me any pointers that would be awesome.
> 
> Thanks for your help 

The question I have is why? Should your upload fail for any reason you've got a 
half processed file that is non-recoverable.  No do-overs. If you stick to the 
standard processes with out the extension,

Upload
Save somewhere (or leave in temp upload folder)
Process
Send result back to user 
Unlink file

Generating the file and sending it to the user is also pretty standard

Create your dataset
Send appropriate headers
Send data
Close connection

For this, there usually isn't a need to save the file. You may run into issues 
streaming the data to certain browsers. 

Also one of the main downsides to your upload is high load situations or large 
file situations (where file size exceeds php's upload limit). 

My personal preference is to save that file to disk so that if needed I can 
work with it later ( if say the server load is high) and email the results to 
the user. 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to