jrbasso/MeioUpload

Strange error when uploading image

bo-oz opened this issue · 4 comments

Hi,

I've just discovered this branche for the MeioUpload behavior. I had just set up the 1.0.1 version, which worked fine. When I discovered it wasn't actually using PHPThumb, I decided to switch to this version. When replacing the code with this one I get the following errors:

Warning (2): file_get_contents() [function.file-get-contents]: Unable to access /phpsKmFIm [CORE/cake/libs/file.php, line 170]
Warning (2): file_get_contents(/phpsKmFIm) [function.file-get-contents]: failed to open stream: Inappropriate ioctl for device [CORE/cake/libs/file.php, line 170]

Also some PHPThumb errors which are probably caused by the PHP errors:

phpThumb() v1.7.10-201104242100

Unknown image type identified by "" () in SourceImageToGD() [3523]

Edit: I have analysed the code and it seems the behavior is using the CakePHP File class to handle the actual upload. Isn't it more easier to just use PHP's move_uploaded_file()? Is there some reason for using the File class?

I fixed this problem by removing the usage of the File class... somehow my CakePHP installation cannot access the temporary file this way.

function _copyFileFromTemp($tmpName, $saveAs, $filePermission) {
        $results = true;
        if (!is_uploaded_file($tmpName)) {
            return false;
        }

        if(move_uploaded_file($tmpName, $saveAs)) {
            chmod($saveAs, $filePermission);    
        } else {
            // if normal upload fails, try the cake way
            $file = new File($tmpName, $saveAs);
            $temp = new File($saveAs, true, $filePermission);

            debug($file);
            debug($temp);

            if (!$temp->write($file->read())) {
                die('test');
                $results = __d('meio_upload', 'Problems in the copy of the file.', true);
            }

            $file->close();
            $temp->close();
        }
        return $results;
    }

Thanks a lot! This fixed it for me too.

Nice it helped :)

Verstuurd vanaf mijn iPhone

Op 3 mrt. 2012 om 00:33 heeft "Nikola Paradzik" reply@reply.github.com het volgende geschreven:

Same to me ;) Thanks


Reply to this email directly or view it on GitHub:
#87 (comment)

Works for me tks!