FAQ
Hello,

I want to change the way file upload processing is done in php. We have a http server (appweb)
that puts the uploaded file to a temp directory. This file has headers at the beginning and end.

I am looking at code rfc1867.c. This code takes the temp file and seems to extract the real file.
I want to change it so instead of entire file, I can run a system awk command to trim the
header lines to get the actual file.

Has anyone done something similar? I cant find the place where the actual file is being read?
Can someone please point to that.

This is php 5.2 on bsd.

Thanks

Search Discussions

  • Matt Wilson at Jun 2, 2009 at 11:18 pm
    I'm not sure if you're looking to change the C implementation or not,
    but you could always bypass the internal processing of the file. Set
    post_max_size to 0 and parse the HTTP_RAW_POST_DATA manually.

    On Jun 2, 2009, at 3:55 PM, Bharat Nagwani wrote:

    Hello,

    I want to change the way file upload processing is done in php. We
    have a http server (appweb)
    that puts the uploaded file to a temp directory. This file has
    headers at the beginning and end.

    I am looking at code rfc1867.c. This code takes the temp file and
    seems to extract the real file.
    I want to change it so instead of entire file, I can run a system
    awk command to trim the
    header lines to get the actual file.

    Has anyone done something similar? I cant find the place where the
    actual file is being read?
    Can someone please point to that.

    This is php 5.2 on bsd.

    Thanks
  • Bharat Nagwani at Jun 2, 2009 at 11:31 pm
    Yes I am looking to change the C implementation.

    The problem is - the uploaded temp file is already created by httpd server even before it gets to php.

    In php I just need to find this temp file, trim the headers and avoid
    file copy by php being done by following code in rfc1867.c

    while (!cancel_upload && (blen = multipart_buffer_read(mbuff, buff, sizeof(buff), &end TSRMLS_CC)))
    {
    if (php_rfc1867_callback != NULL) {
    multipart_event_file_data event_file_data;
    event_file_data.post_bytes_processed = SG(read_post_bytes);
    event_file_data.offset = offset;
    event_file_data.data = buff;
    event_file_data.length = blen;
    event_file_data.newlength = &blen;
    if (php_rfc1867_callback(MULTIPART_EVENT_FILE_DATA,
    &event_file_data, &event_extra_data TSRMLS_CC) == FAILURE) {

    ...

    While following multipart_buffer_read I cannot find the place where it is reading the temp file to fill this buffer.

    Thanks

    -----Original Message-----
    From: Matt Wilson
    Sent: Tuesday, June 02, 2009 4:22 PM
    To: Bharat Nagwani
    Cc: internals@lists.php.net
    Subject: Re: [PHP-DEV] Question on file upload

    I'm not sure if you're looking to change the C implementation or not,
    but you could always bypass the internal processing of the file. Set
    post_max_size to 0 and parse the HTTP_RAW_POST_DATA manually.

    On Jun 2, 2009, at 3:55 PM, Bharat Nagwani wrote:

    Hello,

    I want to change the way file upload processing is done in php. We
    have a http server (appweb)
    that puts the uploaded file to a temp directory. This file has
    headers at the beginning and end.

    I am looking at code rfc1867.c. This code takes the temp file and
    seems to extract the real file.
    I want to change it so instead of entire file, I can run a system
    awk command to trim the
    header lines to get the actual file.

    Has anyone done something similar? I cant find the place where the
    actual file is being read?
    Can someone please point to that.

    This is php 5.2 on bsd.

    Thanks

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJun 2, '09 at 8:55p
activeJun 2, '09 at 11:31p
posts3
users2
websitephp.net

2 users in discussion

Bharat Nagwani: 2 posts Matt Wilson: 1 post

People

Translate

site design / logo © 2022 Grokbase