dream752614590 2013-02-05 20:51
浏览 107
已采纳

php和ajax - 上传base64照片并返回编辑链接

I've tried to make this:

  • Upload photo from a PC as base64 string ("data:image/jpeg;base64,...")
  • PHP will save this photo in full resolition as .jpg and make 160x160 .png thumbnail
  • Then it will return link to full-size image and user will crop this photo using Jcop and send dimensions automaticly when user confirm

I've done this pretty far and it works fine on my local Apache. But when I've moved it to remote web-hosting (I dont have access to shell) the first ajax request (when user submit the photo) returns 401 Unauthorized. I searched for wrong files permissions but I'm not sure if it's problem of photo.php's permissions or the uploaded image's permissions. I've set 0650 to all directories.

Captured request: http://netbox.wayo.cz/401unauthorized.PNG

Here is code that saves the photo:

if($image = imagecreatefromstring($content))
{
     // save full-size photo
     if($photo = imagejpeg($image,$file_path,$control->get_config('upload_photo_quality')))
     {  
        // get photo params
        list($width,$height,$type,$attr) = getimagesize($file_path);

        // create photo thumbnail
        $thumb_name = uniqid().'.png';
        $thumb_path = DIR_DATA.'thumbs/'.$thumb_name;
        imagepng($image,$thumb_path,$control->get_config('upload_photo_compression'));
  • 写回答

1条回答 默认 最新

  • dongshi1606 2013-02-05 21:09
    关注

    you must Set 654, in 650 public user can not access the directory and inner File if You Request For PHP Must Set 655 that allow user to Execute PHP file

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改