php - Show images from temp directory to end users -
i doing image rotate functionality. rotating image , saving tmp directory using
$rotate = imagerotate($source, 90, 0); $rotatedtmpfile = tempnam('/tmp', 'rotatedthumbnailimage'); imagejpeg($rotate, $rotatedtmpfile ,100); files created in tmp folder. want
- read content of tmp directory
- generate url of tmp image file
- send src response ajax call
javascript:
$.ajax({ url: padmin.roateimageurl, data: { mediaid: id[1], src: src }, type: 'post', success: function(response) { img.attr('src', response); } }); - show rotated image end user before uploading on s3 server.
please help.
i'm pretty sure /tmp not accessible via webserver directly. should either move /tmp directory in docroot, or alternatively encode image in html directly; using
$mime = mime_content_type($rotatedtmpfile); $data = file_get_contents($rotatedtmpfile); exit('data:' . $mime . ';base64,' . base64_encode($data)); this should work image-src might resource-expensive
Comments
Post a Comment