diff --git a/motorradig/.idea/workspace.xml b/motorradig/.idea/workspace.xml index d6a608e..a7c446f 100644 --- a/motorradig/.idea/workspace.xml +++ b/motorradig/.idea/workspace.xml @@ -2,11 +2,12 @@ - + + - + @@ -285,10 +287,11 @@ - - + + + \ No newline at end of file diff --git a/motorradig/app/Http/Controllers/FileController.php b/motorradig/app/Http/Controllers/FileController.php index abcce67..e7fd85c 100644 --- a/motorradig/app/Http/Controllers/FileController.php +++ b/motorradig/app/Http/Controllers/FileController.php @@ -10,8 +10,15 @@ class FileController extends Controller { public function upload(Request $request) { - Log::info("Request:"); - Log::info($request); + Log::info("Incoming UploadRequest"); + + $uploadedFile=$request->image; + $filename=$uploadedFile->storeAs('.',$uploadedFile->getClientOriginalName(),'images'); + + //Storage::disk('image_uploads')->put('filename', $file_content); + + +/* Log::info($request); $exploded = explode(',', $request->image); Log::info("exploded:"); @@ -31,7 +38,9 @@ class FileController extends Controller Log::info("Upload endpoint reached."); Log::info("Filename:".$fileName); +*/ - return response()->json([], 200); + //return response()->json([], 200); + return response(['status'=>'success','storedName'=>$filename],200); } } diff --git a/motorradig/config/filesystems.php b/motorradig/config/filesystems.php index ec6a7ce..996e8ab 100644 --- a/motorradig/config/filesystems.php +++ b/motorradig/config/filesystems.php @@ -54,7 +54,12 @@ return [ 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], - + 'images' => [ + 'driver' => 'local', + 'root' => public_path().'/upload/images', + 'url' => env('APP_URL').'/public', + 'visibility' => 'public', + ], 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), diff --git a/motorradig/public/js/app.js b/motorradig/public/js/app.js index 185a1f3..e0f7367 100644 --- a/motorradig/public/js/app.js +++ b/motorradig/public/js/app.js @@ -2181,11 +2181,14 @@ __webpack_require__.r(__webpack_exports__); onFileSelected: function onFileSelected(event) { console.log("File changed:"); console.log(event.target.files[0].name); - var fd = new FormData(); - fd.append('image', event.target.files[0], event.target.files[0].name); - axios.post('http://localhost:8000/api/v1/auth/upload', fd, { + var selectedFile = event.target.files[0]; + var formData = new FormData(); //formData.append('image',selectedFile,selectedFile.name); + + formData.append('image', selectedFile); + var config = axios.post('http://localhost:8000/api/v1/auth/upload', formData, { headers: { - 'Authorization': 'Bearer ' + this.$store.state.user_token + 'Authorization': 'Bearer ' + this.$store.state.user_token, + 'Content-Type': 'multipart/form-data' } }).then(function (res) { console.log(res); diff --git a/motorradig/public/upload/images/Gazprom.png b/motorradig/public/upload/images/Gazprom.png new file mode 100644 index 0000000..9757b40 Binary files /dev/null and b/motorradig/public/upload/images/Gazprom.png differ diff --git a/motorradig/resources/js/views/Upload.vue b/motorradig/resources/js/views/Upload.vue index 9f6819d..8395dae 100644 --- a/motorradig/resources/js/views/Upload.vue +++ b/motorradig/resources/js/views/Upload.vue @@ -125,11 +125,17 @@ onFileSelected(event) { console.log("File changed:"); console.log(event.target.files[0].name); - const fd = new FormData(); - fd.append('image',event.target.files[0],event.target.files[0].name); - axios.post('http://localhost:8000/api/v1/auth/upload',fd,{ + var selectedFile=event.target.files[0]; + const formData = new FormData(); + //formData.append('image',selectedFile,selectedFile.name); + formData.append('image',selectedFile); + + const config= + + axios.post('http://localhost:8000/api/v1/auth/upload',formData,{ headers: { - 'Authorization': 'Bearer ' + this.$store.state.user_token + 'Authorization': 'Bearer ' + this.$store.state.user_token, + 'Content-Type': 'multipart/form-data' } }) .then(res=>{ diff --git a/motorradig/storage/app/public/.gitignore b/motorradig/storage/app/public/.gitignore deleted file mode 100755 index d6b7ef3..0000000 --- a/motorradig/storage/app/public/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore