1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Uploaded files with duplicated content

Discussion in 'PHP' started by fuxia79, Jul 6, 2005.

  1. #1
    Hi all,
    I am using PHP 5 and Apache (Apache/2.0.54 (Unix) mod_ssl/2.0.54 OpenSSL/0.9.7a DAV/2 PHP/5.0.4 ) and I am facing a very starnge situation: when I upload a file, parts of its content are duplicated!!!
    If it is a simple .txt file, I can see repeated parts of text when I download the file, but if I am dealing with .doc, .xls etc the problem is even more serious: the file is perceived as damaged and the related program is not able to open it.
    Neither php log nor the server log display any errors during upload. I compared php.ini and httpd.conf files with those of a previous installation on another computer (Apache/2.0.54 (Unix) DAV/2 PHP/5.0.4 ) where this problem didn't arise and they do not present significant differences. What could be the cause of this misbehaviour? :confused:
    Please, help me, I don't really know what to do!
     
    fuxia79, Jul 6, 2005 IP
  2. davert

    davert Banned

    Messages:
    345
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Could it be a local issue? Have you tried using a different browser or computer? Did you look at the files on the server via pico?
     
    davert, Jul 6, 2005 IP
  3. fuxia79

    fuxia79 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Content is duplicated as files are uploaded by php, BEFORE they are permanently stored on the server. The copy on the server is already damaged.
    I don't think it can be a local issue, I never had problems whit other server machines. Moreover I tried with Mozilla and the behaviour does not change.
    Thanks for your interest, any other ideas?
     
    fuxia79, Jul 6, 2005 IP
  4. rickbkis

    rickbkis Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sounds ugly. I presume ftp uploads work ok?

    Is this through SSL? Have you tried a small test program to isolate the behavior?

    I'm not real familiar with the PHP upload mechanism, but have a lot of experience with buffer transfers - these kinds of things are usually implemented in piecemeal transfers. What it sounds like is a buffer is getting duplicated on input, somehow.

    Usually this sort of thing is done with a socket check: the controlling code is in a loop and it checks the socket - if there's data, it reads it into the buffer, if not, it just passes (assuming it's using non-blocking socket calls). An error would be to not clear the buffer or not set its length to zero or some such thing & the controlling code thinks there's something new to be sent, but it just sends the old buffer.

    If true, that could be way down deep in PHP. Or it could be an OS socket system error. Both could be pretty ugly to try to resolve. Check for recent updates of both.


    I'd try to isolate the behavior with a small program, check to see if it works on other systems, if possible - if it doesn't, it's probably a PHP issue and you would then have to see if you can get PHP's interest on it. If it does, it's an OS issue & you'd need to bring it to their attention.

    Good luck.
    rickb
     
    rickbkis, Jul 7, 2005 IP
  5. rickbkis

    rickbkis Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sounds ugly. I presume ftp uploads work ok?

    Is this through SSL? Have you tried a small test program to isolate the behavior?

    I'm not real familiar with the PHP upload mechanism, but have a lot of experience with buffer transfers - these kinds of things are usually implemented in piecemeal transfers. What it sounds like is a buffer is getting duplicated on input, somehow.

    Usually this sort of thing is done with a socket check: the controlling code is in a loop and it checks the socket - if there's data, it reads it into the buffer, if not, it just passes (assuming it's using non-blocking socket calls). An error would be to not clear the buffer or not set its length to zero or some such thing & the controlling code thinks there's something new to be sent, but it just sends the old buffer.

    If true, that could be way down deep in PHP. Or it could be an OS socket system error. Both could be pretty ugly to try to resolve. Check for recent updates of both.


    I'd try to isolate the behavior with a small program, check to see if it works on other systems, if possible - if it doesn't, it's probably a PHP issue and you would then have to see if you can get PHP's interest on it. If it does, it's an OS issue & you'd need to bring it to their attention.

    Good luck.
    rickb
     
    rickbkis, Jul 7, 2005 IP
  6. fuxia79

    fuxia79 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I used the same program with the same OS on other computers and did't meet any similar problems, thus I don't think it may be a php or OS related issue.

    The detailed situation is the following:
    the problem arises when uploading files to a TikiWiki system (a content manegement system written in php). We do not use SSL, we use standard http; SSL is installed but used only on another virtual host, dedicated to phpMyAdmin (database administration functionality). The server machine contains all binary and configuration files and the DB, while the TikiWiki php files and user uploaded files are on another computer, accessed via NFS.
    Could it be a problem related to NFS configuration?
     
    fuxia79, Jul 8, 2005 IP
  7. fuxia79

    fuxia79 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Mistery solved!!!!:D
    It is an Apache 2 bug, to solve it we just had to make a change in the httpd.conf file.
    Just for knowledge: http://bugs.php.net/bug.php?id=19263
    Thanks again for interest
     
    fuxia79, Jul 8, 2005 IP
  8. rickbkis

    rickbkis Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hmm. Actually, it seems to be an Apache-interacting-with-PHP bug.
    Could be on either side.

    At any rate, it's great you found a workaround. At some point I'm going to have to
    upgrade to PHP5 and Apache2, so it's good to hear reports from the advance scouts.

    (How do those arrows feel?) :)

    rickb
     
    rickbkis, Jul 8, 2005 IP