If you check the XHR response in a debugger, you'll see this {"error":"File was not uploaded.","errorcode":666}
This error comes from Varien_File_Uploader::__construct()
in lib/Varien/File/Uploader.php
Here are the important parts
<?php
class Varien_File_Uploader
{
/**
* Uploaded file handle (copy of $_FILES[] element)
*
* @var array
* @access protected
*/
protected $_file;
const TMP_NAME_EMPTY = 666;
function __construct($fileId)
{
$this->_setUploadFileId($fileId);
if(!file_exists($this->_file['tmp_name'])) {
$code = empty($this->_file['tmp_name']) ? self::TMP_NAME_EMPTY : 0;
throw new Exception('File was not uploaded.', $code);
} else {
$this->_fileExists = true;
}
}
}
Looking back up the trace you see this is called
$uploader = new Mage_Core_Model_File_Uploader('image');
Which is extended from the Varien class, so the Varien_File_Uploader::_setUploadFileId($fileId)
will construct the $this->_file
array based on the key image
, in this case.
So now the problem is why is $_FILES['image']['tmp_name']
empty?
I checked the 'error'
field by temporarily changing the exception to
throw new Exception('File was not uploaded. ' . $this->_file['error'], $code);
I got 7
, which is Failed to write file to disk.
which means it's a permissions issue. Do a phpinfo()
to check where your upload_tmp_dir
is set to and make sure it's writable.
In my case, I was out of file space in the /tmp
dir.