It's really interested, actually I don't know what's going on.
haha,fair enough,so tell me do i need to send my image data thorough $_Files?
No you don't have to. It's just one of superglobal variables in php
Documentation: https://www.php.net/manual/en/language.variables.superglobals.php
okay i read it,so tell me what next should i do?and if it appeals suitable to you then can i share my screen with you so you can better understand what's going on,thanks for your time devotion
First thing what you can do is that you split your one method to two different methods. One for get and another to post.
u mean i should get my image field with other method?
I mean create different action, so 2 different routes for create and store. Because you handle get and post in same method.
https://laravel.com/docs/7.x/controllers#resource-controllers
i just tried that code in my controller and it says undefined index:image,while my image field id is iamge,
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["image"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
@snapey or @bobbybouwmann Could you help what is there a problem?
in your store method put
dd(['posted', Request::all()]);
cut and paste this.
check what this shows when you post the form.
You need to split your controller first into the get route to show the form and a post route to receive the posted data
If the dump that appears does not contain the data you expect, use the browser network tools to see what is being posted.
it gives error
Non-static method Illuminate\Http\Request::all() should not be called statically```
can you people send me some code that successfully stores image in database?
i have tried this on simple php page and it's working there.
Please or to participate in this conversation.