From:             p dot watras at gmail dot com
Operating system: FreeBSD 7.1
PHP version:      5.2.11
PHP Bug Type:     cURL related
Bug description:  cURL does not upload files with specified filename

Description:
------------
This bug is similar to http://bugs.php.net/bug.php?id=48962.
As alexei suggested you have to manually edit interface.c in line 1593:
and change it to:
CURLFORM_FILENAME, filename ? filename+sizeof(";filename=") - 1 : postval

Everything works fine after this update.



Reproduce code:
---------------
# File test1.php

$data = array('file' => '@/tmp/myfile;filename=foobar');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);

echo curl_error($ch);

# File test2.php

$data = array('file' =>
'@/tmp/myfile;filename=foobar;type=application/zip');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);

echo curl_error($ch);

# File upload.php

print_r($_FILES);


Expected result:
----------------
# Result of test1.php

Array
(
    [item_file] => Array
        (
            [name] => foobar
            [type] => application/octet-stream
            [tmp_name] => /var/tmp/phpCEVFto
            [error] => 0
            [size] => 36257
        )

)

# Result of test1.php

Array
(
    [item_file] => Array
        (
            [name] => foobar
            [type] => application/zip
            [tmp_name] => /var/tmp/phpCEVFto
            [error] => 0
            [size] => 36257
        )

)



Actual result:
--------------
Upload fails. No files are uploaded.

-- 
Edit bug report at http://bugs.php.net/?id=49943&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49943&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49943&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49943&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49943&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49943&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49943&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49943&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49943&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49943&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49943&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49943&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49943&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49943&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49943&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49943&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49943&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49943&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49943&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49943&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49943&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49943&r=mysqlcfg

Reply via email to