dongpan1416 2015-05-23 04:50
浏览 124
已采纳

为什么在这个函数之后没有执行file_put_contents()代码行?

i have created one function to upload image using web services.

$image_url=time().$img_name;
$path=$_SERVER['DOCUMENT_ROOT'].'/img';
$image_url_src=$path."/".$image_url;
$current = file_get_contents($image_url_src);
$current = base64_decode($img_url);
            
$res=file_put_contents($image_url_src,$current);
chmod($image_url_src, 0777);
if($res===true)
{
  $folder_img_url1="http://www.example.com/img/".$image_url;
  $auth_error=array("img_url"   => $folder_img_url1); 
  return json_encode($auth_error);
}

Everything is working properly.. only problem is why not returning value after this line of code file_put_contents($image_url_src,$current);

if i return any value before file_put_contents function than it works but after calling file_put_contents() after that not return works so why?

ANY HELP WOULD BE APPRECIATED

</div>
  • 写回答

2条回答 默认 最新

  • doukekui0914 2015-05-23 08:04
    关注

    This Code is works for me...

    $image_url=time().$img_name;
    $path=$_SERVER['DOCUMENT_ROOT'].'/img';
    $image_url_src=$path."/".$image_url;
    //$current = file_get_contents($image_url_src); //this line of code is no need because of this not returning value..because it gives me an error.
    $current = base64_decode($img_url);
    $res=file_put_contents($image_url_src,$current);
    //chmod($image_url_src, 0777);  if will remove than also its works
    if($res===true)
    {
      $folder_img_url1="http://www.example.com/img/".$image_url;
      $auth_error=array("img_url"   => $folder_img_url1); 
      return json_encode($auth_error);
    }
    

    Thank you for your time..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥20 sim800c模块 at指令及平台
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计