2014-12-30 6 views
0

내 경로가 :Laravel 4 500을 받고 항상 작동하지 uploadifile (내부 서버 오류)

Route::get('/file', array(
    'as' => 'files', 
    'uses' => '[email protected]' 
)); 

Route::post('/uploadfile', array(
    'as' => 'uploadfile', 
    'uses' => '[email protected]' 
)); 

지금 난 내/파일 경로에 uploadifive 설정 및 보내는 POST 요청이에/UploadFile로

UploadFile로에 대한 코드는 여기에 있습니다 :

$file = Input::file('file_upload'); 
    $destinationPath = 'files/CDN/'.str_random(8); 
    echo $filename = $file->getClientOriginalName(); 
    $extension =$file->getClientOriginalExtension(); 
    $uploadSuccess = Input::file('file')->move($destinationPath, $filename); 

하지만 항상 내가 무엇입니까 500 (내부 서버 오류)

나는 CHMOD가 0777 하고 난/UploadFile로에서 위의 코드를 제거하고 성공을 반환

echo 200; 

을 배치 할 때 내가 같이 우측 경로에 연결하고 내 디렉토리를 확인했습니다.

블레이드 폼 태그도 추가하려고했지만 uploadifive는 실제로 폼 요소에 전혀 의존하지 않습니다. 그것은 AJAX로 게시됩니다.

+0

처럼 당신이'$ 파일 -을 사용한다고 생각> 모 ve()'마지막 줄에 – lukasgeiter

+0

$ file-> move()가 코드 대신 작동 할 수있는 이유는 파일에 액세스하려는 두 개의 다른 필드 이름 ('file_upload'및 'file '(처음과 마지막 줄을보십시오). 첫 줄을 양식에서 지정하는 것으로 변경하고 $ file-> move ($ destinationPath, $ filename); 마지막 줄에. – Laravelian

+0

안녕하세요, 나는 차이점이없는 $ 파일로 바꾸려고했습니다. 그것도 여전히 동일한 결과를 보여줍니다 : 콘솔'http : // scrumy.co.uk/file' –

답변

0

드디어 블레이드 Laravel 접근 방식을 통해 정상적인 파일 게시 양식에서 응답의 var_dump가 표시되면 Uploadfile 객체가 양식 필드에 지정된 파일 이름으로 생성되지만 다른 한편으로 Uploadifive를 통해 동일한 요청을 보내면 [FileData]라는 노드를 포함하는 배열을 전송한다는 것을 알 수 있습니다. 기본적으로이 객체 포인터를 $ file 변수에 할당해야합니다. 그것은 완벽하게 작동합니다

$data    = Input::all(); 
$file    = $data['Filedata']; 
$destinationPath = public_path().'files/'.str_random(8); 
$filename   = $file->getClientOriginalName(); 
$extension   = $file->getClientOriginalExtension(); 
$uploadSuccess  = $file->move($destinationPath, $filename); 
if($uploadSuccess) { 
    return Response::json('success', 200); 
} else { 
    return Response::json('error', 400); 
} 

작품의 매력 :