Magento image load error: fileUploadErrorCantWrite

Posted . Visible to the public.

The error is coming from Mage_Catalog_Model_Product_Option_Type_File but it is not interpreted in _getValidatorErrors(). The error happens repeatedly for certain users and not other users.

In $fileInfo = $upload->getFileInfo($file);, the error is 7. For example:

Array
(
    [name] => YU XIA.jpg
    [type] => 
    [tmp_name] => 
    [error] => 7
    [size] => 
    [options] => Array
        (
            [ignoreNoFile] => 
            [useByteString] => 1
            [magicFile] => 
            [detectInfos] => 1
        )

    [validated] => 
    [received] => 
    [filtered] => 
    [validators] => Array
        (
            [0] => Zend_Validate_File_Upload
        )

    [title] => YU XIA.jpg
)

Looking at the source code, I deduce that the uploaded file is saved in the system tmp directory, /tmp. When PHP cannot write the file in /tmp, it throws this error. So, the error occurs way before the file is Rename (as a filter in Zend_File_Transfer), or moved to the ../media/custom_options/quote/. Compare to this error, which happened when the file is saved in the /tmp:

Array
(
    [name] => kiat1a.JPG
    [type] => image/jpeg
    [tmp_name] => /tmp/phpivaSBH
    [error] => 0
    [size] => 360225
    [options] => Array
        (
            [ignoreNoFile] => 
            [useByteString] => 1
            [magicFile] => 
            [detectInfos] => 1
        )

    [validated] => 
    [received] => 
    [filtered] => 
    [validators] => Array
        (
            [0] => Zend_Validate_File_Upload
        )

    [title] => kiat1a.JPG
)

Resolution

Remove all the temporary image files in /tmp. The file names are prefixed with 'php' as in the above example.
There may be a size constraint on /tmp. This can be easily tested by FTP a sizable file to /tmp. Besure to test all servers in a load balance configuration.

kiatng
Posted by kiatng to OpenMage (2014-03-07 02:05)