0
2つの異なる場所にファイルをアップロードしようとしています。塗りは/2x/
とadn /3x/
です。それは3倍にファイルをアップロードしますが2倍にしないと、このエラーがスローされます。ここではLaravel:不明なエラーのためファイルがアップロードされていません
The file was not uploaded due to an unknown error
は私がやっているものです:
$photo = $request->file('photo');
if (isset($photo)) {
if ($photo != null || $photo != '') {
$imageSize = getimagesize($photo);
$resolution = $imageSize[0] . 'x' . $imageSize[1];
if ($resolution == '300x300' || $resolution == '450x450') {
if (!file_exists(base_path('uploads/custom_avatar'))) {
mkdir(base_path('uploads/custom_avatar'), 0777, true);
}
$resolution = "3x";
$uploadPath = base_path('uploads/custom_avatar/' . $resolution . '/');
$otherImageResolution = '2x';
$otherImagePath = base_path('uploads/custom_avatar/' . $otherImageResolution . '/');
// echo $otherImagePath;exit;
// saving image
$fileName = $child->id . '_' . time() . '.png';
$photo->move($uploadPath, $fileName);
$photo->move($otherImagePath, $fileName);
// creating records
$childImage = Images::addPhoto($child->id, $fileName, $resolution);
$otherImage = Images::addPhoto($child->id, $fileName, $otherImageResolution);
if ($childImage && $otherImage) {
$result = Child::createChildResponseData($child);
\Log::info('Child avatar added Successfully' . json_encode($childImage));
return response()->json([
'status' => $this->SUCCESS,
'response' => $result,
], $this->SUCCESS);
}
任意のヘルプ?
移動したり、複数の場所への要求からファイルをコピーします[ stackoverflowの質問](https://stackoverflow.com/questions/38979386/move-or-copy-a-file-from-the-request-to-multiple-locations) –
ありがとう@SurenderSinghRawat、それは働いた。 – Saani