上传文件到新浪云Storage的方法
上传文件到新浪云Storage的方法,兼容本地服务器
if (!empty($_FILES['sharepic']['name'])){ $tmp_file = $_FILES['sharepic']['tmp_name']; $file_types = explode(".", $_FILES['sharepic']['name']); $file_type = $file_types[count($file_types) - 1]; /*设置上传路径*/ if (isset($_SERVER['HTTP_APPNAME'])){//SAE $file_name = time().".".$file_type; $s = new \SaeStorage(); $s->upload('rpunion', $file_name, $tmp_file); $file_name = $s->getUrl('rpunion', $file_name); }else { $file_name = "Uploads/".time().".".$file_type; if (!move_uploaded_file($tmp_file, $file_name)){ $this->error ('文件上传失败,请关注方倍工作室账号'); } $file_name = "http://".$_SERVER['SERVER_NAME']."/".$file_name; } // var_dump($file_name); $Form->sharepic = $file_name; }else{ }
本文来自博客园,作者:方倍工作室,转载请注明原文链接:https://www.cnblogs.com/txw1958/p/sae-storage-file-upload.html