Answer the question
In order to leave comments, you need to log in
How to store image path in db?
I save the data that came from the form in the images[] array
, I also have image_1,image_2,image_3...image_5 these are the fields in the database where I want to save the paths to the pictures
Pictures are saved like this:
$Form->images = UploadedFile::getInstances($Form,'images');
foreach($Form->images as $file){
$file->saveAs('uploads/' . $file->baseName . '.' . $file->extension);
}
Answer the question
In order to leave comments, you need to log in
$images = UploadedFile::getInstances($Form,'images');
$path1 = 'uploads/' . $images[0]->baseName . '.' . $images[0]->extension;
$image[0]->saveAs($path1);
$imageModel = new ImageModel(...);
$imageModel->image1 = $path1;
$imageModel->image2 = $path2;
$imageModel->save();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question