简体   繁体   English

在CakePHP中从FLASH上传图像

[英]Uploading images from FLASH in CakePHP

I'm having trouble handling my images created from my flash application, it sends the data via raw post data, and it's writing the image to my /webroot folder. 我在处理从Flash应用程序创建的图像时遇到了麻烦,它通过原始发布数据发送数据,并将图像写入到/ webroot文件夹中。

Here's the php code I have in an "AvatarController.php" file. 这是我在“ AvatarController.php”文件中拥有的php代码。

public function uploadImage()
{
    $this->autoRender = false; // no view file

    if ($this->request->is('post')) // if post data
    {
        $aUser = $this->aCurrentUser(); // gets user info

        if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) // gets raw post data
        {
            $sImgName = $aUser['User']['username'] . '_full' . '.png';

            $fp = fopen($sImgName, "wb");
            fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );
            fclose( $fp );
        }

    }
}

what I'm having trouble with is saving this into a different folder eg /webroot/avatars, and how would I go about resizing the image, ultimately what I want to do is have three or so sizes, so for example "Username_full", "Username_80", "Username_50"; 我遇到的麻烦是将其保存到其他文件夹(例如/ webroot / avatars)中,然后如何调整图像的大小,最终我要做的是设置3个左右的大小,例如“ Username_full”, “ Username_80”,“ Username_50”; so the full size, 80% smaller, 50% smaller, etc. 因此全尺寸,缩小80%,缩小50%,依此类推。

I've just never handled uploads like this, from flash. 我从来没有从Flash处理过这样的上传。

Any help, suggestions? 任何帮助,建议吗?

http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html

This looks like a decent tutorial on the resize/move business PHP. 这看起来像是有关调整大小/移动业务PHP的不错的教程。 The other part with regard to grabbing the file itself, see this post, http://www.kirupa.com/forum/showthread.php?360502-AS3-PHP-File-Upload what you're doing may work but I just tend to use the $_FILES variable as it's clear to me what's going to be in there. 关于抓取文件本身的另一部分,请参阅这篇文章, http: //www.kirupa.com/forum/showthread.php?360502-AS3-PHP-File-Upload您正在执行的操作可能有效,但我只是倾向于使用$ _FILES变量,因为对我来说很明显会有什么变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM