我最近在Godaddy上主持过,直到我的程序尝试在laravel公共文件夹中上传文件。
该网站非常有用,但我无法使用下面的帖子方法和服务上传文件 这是angularjs服务/结账我的服务在localhost
工作正常services.factory('Game', ['$http', function($http){
return {
get:function(){
return;
}
, post:function(documentData){
return $http(
{ method: 'POST',
url: 'public/Game/store',
// headers: { 'content-type': 'multipart/form-data'},
data: documentData
});
}
,fbImageUpload:function(docData){
return $http(
{ method: 'POST',
url: 'public/Game/create',
// headers: { 'content-type': 'multipart/form-data'},
data: docData
});
}
};
}]);
我正在调用这样的服务
docData={"uprofile":$scope.picture.picture.data.url,
"gameName":$scope.gameName,
"userId":$scope.picture.id};
console.log(docData);
drawText("Please wait ... ",50,50,"mainCanvasD");
Game.fbImageUpload(docData).success(function (res){
drawUrlImage("game/"+$scope.gameName+"/profile/back.jpg",0,0,540,320,"mainCanvasD");
console.log("profile picture");
drawUrlImage(res.data,30,130,180,180,"mainCanvasD");
console.log("fb profile");
drawUrlImage("game/"+$scope.gameName+"/right/"+Math.floor(Math.random() * 10)+".jpg",320,130,180,180,"mainCanvasD");
console.log("emperor profile");
$scope.enableShare=true;
$scope.loading=false;
}).error(function (res){
console.log("fb Image upload to server werajale failed");
console.log(res);
});
我的laravel后备代码
*/
public function create(Request $request)
{
$file = $request->uprofile;
// Open the file to get existing content
$data = file_get_contents($file);
// New file
$new = "game/".$request->gameName."/play/".$request->userId.".jpg";
// Write the contents back to a new file
file_put_contents($new, $data);
// $url = $request->uprofile;
// $file = file_get_contents($url);
// $file->move("game/".$request->gameName."/play/",$request->userId.".jpg");
// $image = Image::make($request->uprofile)->save("game/".$request->gameName."/play/".$request->userId.".jpg");
return Response(["data"=>"game/".$request->gameName."/play/".$request->userId.".jpg"]);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
try {
file_put_contents( "game/".$request->gameName."/play/".$request->gameName.$request->userId.".jpg",
// base64_decode($request->image)
base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $request->image))
);
return Response(["status"=>"true","data"=>"http://localhost/ezone/public/"."game/".$request->gameName."/play/".$request->gameName.$request->userId.".jpg"]);
// }else {
// return Response(["success"=>false,"message"=>"Invalid Image argument"]);
// }
} catch (Exception $e) {
return Response(["status"=>false,"message"=>$e.""]);
}
}
我让它在我当地的laravel安装工作,可能是一个许可的事情,但不能在goddady.com完成它
我如何更改公共文件夹的权限,以便我的程序将文件上传到公用文件夹。