2014-09-24 2 views
1

이미지 파일을 서버에 업로드하려고하면 무작위로 오류가 발생하고 가끔은 같은 파일에 문제없이 잘 작동합니다.laravel을 사용하여 파일을 업로드 할 때 알 수없는 오류가 발생했습니다.

Symfony \ Component \ HttpFoundation \ File \ Exception \ FileException 
The file "xxxxxx.jpg" was not uploaded due to an unknown error. 

이 내 코드입니다 :

if (Input::hasFile('thumbnail_image')){ 
    // Upload Photo 
    $thumbnailImage = Input::file('thumbnail_image'); 
    $filename = 'thumbnail.'.Input::file('thumbnail_image')->getClientOriginalExtension(); 
    $destinationPath = 'training_product/article_id_'. $id .'/thumbnail_image'; 
    $databasePath = '/adidas/public/training_product/article_id_'. $id.'/thumbnail_image'; 
    $uploadFile = Input::file('thumbnail_image')->move($destinationPath, $filename); 
    $product->thumbnail_images_path = $databasePath.'/'.$filename; 
    $product->save(); 
} 
+1

laravel 로그 파일에 유용한 정보가 있습니까? –

+1

laravel 로그가 알 수없는 오류를 반환합니다. $ uploadFile = Input :: file ('thumbnail_image') -> move ($ destinationPath, $ filename); 그리고 내가 파일을 업로드 한 것 같아요하지만 어떤 설정이 잘못 알고 때로는 때로는 작동하지 않고 때로는 작동하지 않는다 –

+0

파일이 대상 위치에 이미 있으면 어떻게됩니까? – Gagan

답변

0

대상 폴더에 파일 권한은 무엇입니까? 나는 약간의 코드를 수정 한

sudo chmod -R 777 adidas/public/training_product 그것은 나를 위해 작동

```

if (Input::hasFile('thumbnail_image')){ 
     // Upload Photo 
     $product = new Product; 
     $thumbnailImage = Input::file('thumbnail_image'); 
     $ext = $thumbnailImage->guessExtension(); 
     $filename = 'thumbnail_'. time() . $ext; 
     $destinationPath = 'training_product/article_id_'. $id .'/thumbnail_image'; 
     $databasePath = '/adidas/public/training_product/article_id_'. $id.'/thumbnail_image/'; 
     $thumbnailImage->move($destinationPath, $filename); 
     $product->thumbnail_images_path = $databasePath . $filename; 
     $product->save(); 
    } 

``:. 777로 변경 (당신이 리눅스 서버를 사용하는 가정을보십시오. 나는 또한 폴더 권한은 나에게 파일을 업로드 할 수 있도록 것이라고 확인했다. 당신이 일을 보지 못했다으로`

내가 guessExtension()getClientOriginalExtension()을 변경 한, 새로운 $product을 인스턴스화.

희망이 있습니다.

+0

권한을 777로 변경했으며 소유자/그룹이 정확합니다. 코드로 변경되었습니다. 함수 추측 ($ 경로)에서 오류가 발생했습니다. FileNotFoundException "/ var/www/html/tmp/php1wJ9ca"파일이 없습니다. –

관련 문제