Answer the question
In order to leave comments, you need to log in
What's weird about uploading images?
Created an Image model to load a file into it, here is its code:
class Image
{
public $file;
public function hash() {
return $this->file->hashName();
}
public function saveFile() {
$name = $this->hash();
if($this->file->move(public_path() . '/imgs', $name)) {
return $name;
}
}
}
D:\OServer\OpenServer\userdata\temp\php1BD6.tmp
public function store(JournalStoreRequest $request) {
$journal = new Journal;
$image = new Image;
$image->file = $request->file('image');
$journal->image = $image->saveFile();
if($journal->fill($request->all()) && $journal->save()) {
redirect()->route('journals.index');
}
}
$journal->image = $image->saveFile();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question