2012-09-12 137 views
0

我正在删除iPhone上的应用程序。 我的合伙人向我发送curl命令这样无法上传图片

curl -F "clothing_item[photo][email protected]" -F "clothing_item[name]= pink_dress" http://www......com/shop_items.json?auth_token=abc_xyz_123 

,并问我要实现哪些应对的图像上传到服务器的功能。 我试过

forge.ajax({ 
    url: "http://www........com/shop_items.json", 
    type: "POST", 
    dataType: 'json', 
    data: { 
     "auth_token": token, 
     "clothing_item[photo]": imageFile, 
     "clothing_item[name]": id + "-" + d.getTime().toString()    
    }, 

    success: function(data) { 

    }, 
    error: function(error) { 

    } 
}); 

使用imageFile是来自相机的文件。这篇文章是成功的,但没有图像上传到服务器。

相关搜索:

forge.ajax({ 
    url: "http://www........com/shop_items.json", 
    type: "POST", 
    dataType: 'json', 
    file:[imageFile]; 
    data: { 
     "auth_token": token, 
     "clothing_item[photo]": imageFile, 
     "clothing_item[name]": id + "-" + d.getTime().toString()    
    }, 

    success: function(data) { 

    }, 
    error: function(error) { 

    } 
}); 

,但它不工作。

任何意见表示赞赏

回答

1

这里有一些指南,以帮助您调试虽然它真的很难知道究竟是这里的问题。

  • 打开Charles Proxy并运行iOS模拟器。检查什么是越来越贴在clothin_item [照片]字段
  • 使用Trigger.IO Catalyst远程调试器看网络选项卡,并可能调用类似请求手动
  • 通过观察阿贾克斯request API好像把钥匙是“文件”而不是'文件'。如果我理解正确,则不应将图像发布到其他字段'clothing_item [photo]'上。此外(再次,如果我理解正确),二进制文件字段名称是'文件',不能自定义。
+0

谢谢阿隆。我会要求我的朋友删除'clothing_item [photo]'字段 –