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.
Here's the php code I have in an "AvatarController.php" file.
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"; so the full size, 80% smaller, 50% smaller, etc.
I've just never handled uploads like this, from flash.
Any help, suggestions?
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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.