Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save INDIAN2020/9681591 to your computer and use it in GitHub Desktop.
Save INDIAN2020/9681591 to your computer and use it in GitHub Desktop.
public function uploadImage($file, $field){
if (Input::hasFile($field)) {
$oldimage = $file->$field; // Fetch old image
File::delete(public_path()'/uploads/' . $oldimage); // The destination were you store the image.
}
$destinationPath = public_path().'/uploads/'; // The destination were you store the image.
$filename = $file->getClientOriginalName(); // Original file name
$upload_success = $file->move($destinationPath, $filename); // Now we move the file to its new home.
$storing_path = 'uploads/'.$filename; // store file name into the database.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment