我在处理从我的 Flash 应用程序创建的图像时遇到问题,它通过原始发布数据发送数据,并将图像写入我的 /webroot 文件夹。
这是我在“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 );
}
}
}
我遇到的麻烦是将其保存到不同的文件夹中,例如/webroot/avatars,我将如何调整图像大小,最终我想要做的是有三个左右的大小,例如“Username_full”, “用户名_80”,“用户名_50”;所以全尺寸,小 80%,小 50%,等等。
我从来没有处理过像这样的上传,来自闪存。
任何帮助,建议?