Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error when uploading image #87

Open
bo-oz opened this issue Aug 1, 2011 · 4 comments
Open

Strange error when uploading image #87

bo-oz opened this issue Aug 1, 2011 · 4 comments

Comments

@bo-oz
Copy link

bo-oz commented Aug 1, 2011

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?

@bo-oz
Copy link
Author

bo-oz commented Aug 1, 2011

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;
    }

@Jpunt
Copy link

Jpunt commented Nov 20, 2011

Thanks a lot! This fixed it for me too.

@bo-oz
Copy link
Author

bo-oz commented Mar 2, 2012

Nice it helped :)

Verstuurd vanaf mijn iPhone

Op 3 mrt. 2012 om 00:33 heeft "Nikola Paradzik" [email protected] het volgende geschreven:

Same to me ;) Thanks


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

@miguelcasares
Copy link

Works for me tks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants