Iphone 无法从钛合金相机上传图片
我对钛有一个非常奇怪的问题,我已经搜索了很多资料来解决这个问题,但是我再也找不出答案了 情况就是这样: 我想把我刚用Iphone拍的照片上传到我的服务器上。后端由PHP/Laravel制作 问题是: 每次我上传图片时,titanium都会给我一个错误:HTTP错误 后端:Iphone 无法从钛合金相机上传图片,iphone,laravel-5,titanium-mobile,titanium-alloy,Iphone,Laravel 5,Titanium Mobile,Titanium Alloy,我对钛有一个非常奇怪的问题,我已经搜索了很多资料来解决这个问题,但是我再也找不出答案了 情况就是这样: 我想把我刚用Iphone拍的照片上传到我的服务器上。后端由PHP/Laravel制作 问题是: 每次我上传图片时,titanium都会给我一个错误:HTTP错误 后端: $userID = Authorizer::getResourceOwnerId(); $awsLocation = 'lonelylover.s3-website-eu-west-1.amazonaws.com/';
$userID = Authorizer::getResourceOwnerId();
$awsLocation = 'lonelylover.s3-website-eu-west-1.amazonaws.com/';
$uploadProfilePic = new AwsUpload('source','posts/','posts/');
$uploadProfilePic->upload();
$posts = DB::table('Posts')->insert(
array(
'user_id'=>$userID,
'Event_id'=>Request::input('event_id'),
'description'=>Request::input('description'),
'status'=>'public',
'source'=>$awsLocation.$uploadProfilePic->getUploadedFile(),
)
);
if($posts){
return Response::json(array('meta'=>array('code'=>200),'data'=>"resource sucesfully created"));
}
钛:
var url = "myurl.com?access_token=abcder898";
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'camera_photo.png');
f.write(args.picture);
var data_to_send = {
event_id: 2,
description:"Upload from titanium",
source:f.read()
};
Ti.API.info(data_to_send);
var xhr = Ti.Network.createHTTPClient({
onload: function(e) {
// this function is called when data is returned from the server and available for use
// this.responseText holds the raw text return of the message (used for text/JSON)
// this.responseXML holds any returned XML (including SOAP)
// this.responseData holds any returned binary data
Ti.API.info(JSON.parse(this.responseText));
alert('success');
},
onerror: function(e) {
// this function is called when an error occurs, including a timeout
Ti.API.info(e.error);
alert('error');
},
timeout:5000 /* in milliseconds */
});
xhr.open("POST", url);
xhr.setRequestHeader('Content-Type','multipart/form-data');
xhr.send(data_to_send);
有没有人能帮我解决这个问题,因为我真的没有选择的余地了
Tnx.工作正常。很可能是后端出现问题。请与您的网站管理员联系,将其设置为允许POST请求 状态码是什么?@EduardoGomez我有一个405状态码。。。我不知道为什么。。这描述了405状态代码错误:不允许方法请求行中指定的方法不允许用于由请求URI标识的资源。响应必须包含一个Allow标头,其中包含请求资源的有效方法列表。好的。获取错误:[INFO]在此服务器上找不到请求的URL。您要点击的完整URL是什么?我要点击的URL位于我的开发环境上,该环境运行在Virtualbox上,安装了Homestead和Laravel。请尝试其他Rest客户端。i、 e.对拉威尔一点也不熟悉。对不起,这是奇怪的事情,我已经做了拉威尔自己的后端。当我输出路由列表时,它表示资源uri只接受post请求:post | api/v1/media | api.v1.media.store projectname\Http\Controllers\PostController@store奇怪的是,当我用邮递员测试代码时,它工作得很好。。。这就是为什么我感到困惑。