Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p>Upload Youre Photos Here:</p>
- <form action="{{ route('photos.store') }}" method="POST"
- class="dropzone"
- id="addPhotosForm">
- {{ csrf_field() }}
- </form>
- public function store(Request $request, Banner $banner)
- {
- $file = $request->file('file');
- $name = time() . $file->getClientOriginalName();
- $file->move('banner/photos', $name);
- Photo::create([
- 'path' => "banner/photos/{$name}",
- 'banner_id' => $banner->id,
- 'name' => $name,
- ]);
- return 'Done';
- }
- SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'banner_id' cannot be null (SQL: insert into `photos` (`path`, `banner_id`, `name`, `updated_at`, `created_at`) values (banner/photos/1474787058014ed562a8f945428240a83dbc8baa0d.jpg, , 1474787058014ed562a8f945428240a83dbc8baa0d.jpg, 2016-09-25 07:04:18, 2016-09-25 07:04:18))
- init: function () {
- this.on('sending', function (file, xhr, formData) {
- formData.append("banner_id", 1);
- });
- this.on("success", function (file) {
- swal({
- title: "Success",
- text: "Your Photo has been uploaded!",
- type: "success",
- timer: 2000,
- showConfirmButton: false,
- });
- window.setTimeout(function () {
- location.reload();
- }, 2000)
- });
- },
- };
- </script>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement