2016-10-05 53 views
1

我使用一些參數從iOS發佈數據。我已經將圖像轉換爲字節並將其上傳到服務器。參數的數據已成功保存。但我無法檢查是否出現任何圖像。有沒有什麼方法或什麼來檢查請求中是否存在任何圖像?以下是用於存儲數據的代碼。其他任何工作都很好,除了圖片,我相信。字節由iOS應用程序成功發送。我無法處理或提取請求中的圖像。如何檢查圖像是否存在laravel

public function createIdea(Request $request) { 
    $filename = ''; 
    if ($request->hasFile('idea_image')) { 
     $filename = $request->file('idea_image')->getClientOriginalName(); 
     $moveImage = $request->file('idea_image')->move('images', $filename); 
    } 
    $idea = new Idea(); 
    $idea->idea_info = $request->input('idea_title'); 
    $idea->idea_info = $request->input('idea_info'); 
    $idea->idea_image = "images/".$filename; 
    $idea->idea_location = $request->input('idea_location'); 
    $idea->idea_description = $request->input('idea_description'); 
    $idea->idea_description = $request->input('selection'); 
    $idea->user_id = \Auth::id(); 
    dd($idea); 
    $idea->save(); 
    $ideaId = $idea->id; 
    if (! $idea->id) { 
     $statusCode =404; 
     response()->json(array('Status:' => 'Idea Creation FAILED'),$statusCode); 
    }else{ 
     $response = $idea->toJson(); 
     $statusCode =200; 
     return response()->json(array('Status:' => 'Idea Created Successfully', 'ideaId' => $ideaId),$statusCode); 
    } 
} 

回答

1

簡單。

if (File::exists($myfile)) { 
    echo "Yup. It exists."; 
}