Я пишу загрузку script, и хотя я использую встроенную функцию Laravel в функции Input:: file(), она все равно возвращает null. Я собираюсь опубликовать свой код Home Controller.
public function handleUpload()
{
$user = Auth::user();
$username = $user->username;
$userId = $user->id;
$path_to_users = "users";
$user_profile_img = 'users/'.$username.$userId.'/'.$username.'image001.jpg';
$user_path_profile = "users/$username$userId";
$user_image_name = $username.'image001.jpg';
if(file_exists($path_to_users))
{
if(file_exists("$user_path_profile")){
$file = Input::file('profile')->move("$user_path_profile/", $user_image_name);
} else {
mkdir("$user_path_profile");
$file = Input::file('profile')->move("$user_path_profile/", $user_image_name);
}
} else {
mkdir("users");
mkdir("$user_path_profile");
$file = Input::file('profile')->move("$user_path_profile/", $user_image_name);
}
}
Когда я умираю (var_dump (Input:: file ('profile'))) возвращает null, что означает, что он в основном не принимает в моем файле как фактический файл. Когда я умираю (var_dump (Input:: get ('profile')), он возвращает имя изображения, означающее, что моя загрузка script работает, но бэкэнд Laravel не работает. Это правда, или я просто что-то пропустил?
Вот мой HTML-материал:
@if($user->id == $userProf->id)
<div class="fileUpload button-success pure-button">
<span>Upload</span>
<form action="{{action('[email protected]')}}" method="POST" enctype="multipart/form-data">
<input type="file" name="profile" class="upload" />
</form>
</div>
@endif