2012-09-12 193 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]'字段 –