Image Not Uploading
if ($request->hasFile('imageOne')) {
$pathOne = Storage::putFile('storage/photos', $request->imageOne);
}
How your HTML form looks?
Do you have the enctype="multipart/form-data" attribute on form tag?
@denkata
<form class="form-floating" action="{{ route('article.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="modal-body">
<div class="form-floating mb-3">
<input name="head" type="text" class="form-control" id="floatingInput"
placeholder="[email protected]">
<label for="floatingInput">Head</label>
</div>
<div class="form-floating">
<textarea name="body" class="form-control" placeholder="Leave a comment here"
id="floatingTextarea"></textarea>
<label for="floatingTextarea">Body</label>
</div>
<div class="mb-3 mt-3">
<input name="imageOne" class="form-control" type="file" id="formFile">
</div>
<div class="mb-3 mt-3">
<input name="imageTwo" class="form-control" type="file" id="formFile">
</div>
<div class="mb-3 mt-3">
<input name="imageThree" class="form-control" type="file" id="formFile">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Create</button>
</div>
</form>
So this does not trigger?
if ($request->hasFile('imageOne')) {
dd('hit');
@Sinnbeck I am getting the hit. Also my $pathOne etc... is filling.
$article = new Article;
$article->user_id = Auth::user()->id;
$article->head = $request->head;
$article->body = $request->body;
$article->imageOne = $pathOne;
$article->imageTwo = $pathTwo;
$article->imageThree = $pathThree;
3 | storage/photos/5cOvs5vcRU7oDAM62oqHNQgcHbLtBdeuMTqJJalG.jpg | storage/photos/5cOvs5vcRU7oDAM62oqHNQgcHbLtBdeuMTqJJalG.jpg | storage/photos/5cOvs5vcRU7oDAM62oqHNQgcHbLtBdeuMTqJJalG.jpg
@Randy_Johnson imageOne, imageTwo and imageThree properties; they all have the same path???
Thanks everyone for the help. Turns out the file location was wrong. Always leaves me scratching my head.
But now the string in the database is wrong and I have to perform some string slicing and dicing. Is there another way?
$pathOne = Storage::putFile('public/photos', $request->imageOne);
public/photos/8cbTw0PXQj1ROCL8AFvDofFYV4oFHLA4Cnz4U919.jpg
Please or to participate in this conversation.