【发布时间】:2018-11-24 11:31:59
【问题描述】:
我目前正在研究 Laravel,我创建了一个符号链接,将公共目录连接到存储使用:
php artisan storage:link
在目录中,我有另一个名为user_uploads 的文件夹,用于保存用户上传的文件。我有一个如下所示的输入字段:
<input type="file" name="image[]" id="imgInp" accept="image/jpeg, image/png, image/bmp, image/svg" multiple="multiple">
我验证文件,然后我要做的是:
$image = $request->image;
if($image){
foreach($image as $image){
$image = (array) $image; //convert the object to array
// Now, I need to create the directory here and save the image(s) there
// And, I have to name the folder the id of the row (row means the row of the database where the entry is saved).
}
}else{
return "No image selected";
}
那么,我该怎么做呢?顺便说一句,我想要的文件夹是:
myProject/public/storage/user_uploads.
【问题讨论】:
标签: php html laravel-5.2 storage create-directory