masumluf's avatar

'Axios' The requested resource /gallery was not found on this server.

Hello Developers, This is my route list

       | web          |
|        | GET|HEAD  | gallery                                            | gallery.index             | App\Http\Controllers\GalleryController@index
       | web          |
|        | POST      | gallery                                            | gallery.store             | App\Http\Controllers\GalleryController@store
       | web          |
|        | GET|HEAD  | gallery/create                                     | gallery.create            | App\Http\Controllers\GalleryController@create
       | web          |
|        | GET|HEAD  | gallery/{gallery}                                  | gallery.show              | App\Http\Controllers\GalleryController@show
       | web          |
|        | PUT|PATCH | gallery/{gallery}                                  | gallery.update            | App\Http\Controllers\GalleryController@update
       | web          |
|        | DELETE    | gallery/{gallery}                                  | gallery.destroy           | App\Http\Controllers\GalleryController@destroy
       | web          |
|        | GET|HEAD  | gallery/{gallery}/edit                             | gallery.edit              | App\Http\Controllers\GalleryController@edit
       | web          |

and this is my vuejs method for uploading file.

 uploadfile() {
      if (!this.file_names.length) {
        console.log("no file has been selected");
        return false;
      }
      for (let i = 0; i < this.file_names.length; i++) {
        this.form.append('pics[]', this.file_names[i]);
      }
      const config = { headers: { 'content-Type': 'multipart/Form-data' } };

      axios.post('/gallery', this.form, config)
        .then(res => {
          console.log(res);
        })
        .catch(error => {
          console.log(error);
        })
    }
  }

when i click upload it shows me POST http://127.0.0.1:8000/gallery 404 (Not Found)

0 likes
10 replies
Sinnbeck's avatar

And you dont have any other routes at all, which are not listed here?

If not, can you then show the content of the store method?

masumluf's avatar

actually i used /gallery in the axios thats why i only put gallery resource here. and I never use gallery resource anywhere. and controller i just echo "ok";

public function store(Request $request)
    {
    echo "ok";
    }
Sinnbeck's avatar

It should be (not that it whats causing the problem)

public function store(Request $request)
    {
    return "ok";
    }

But what I mean is do you have any routes that are not related to the gallery? My guess would be that you hit some other route instead of gallery.

Perhaps consider posting the content of web.php

masumluf's avatar
Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/logout', 'Auth\LoginController@logout');

Route::view('/form', 'student.login');
Route::view('/tform', 'Teacher.login');

//admin

Route::post('/searchstudent/{p}', 'AdminController@searchStudent');

Route::get('/admin/index', 'AdminController@index');

Route::get('/teacherlist', 'AdminController@allTeacher');
Route::get('/allstudent', 'AdminController@allStudent');
Route::get('/send', 'AdminController@send');


Route::get('/allattendence', 'AdminController@all_attendence_view');
Route::post('/attendence/get_student_list/{class_name}/{section}', 'AttendenceController@get_student_attendence');
Route::Resource('/attendence', 'AttendenceController');



Route::get('/student/getid', 'StudentController@getId');
Route::post('/student/login', 'StudentController@login');
Route::get('/student/logout', 'StudentController@logout');




Route::get('/teacher/logout', 'TeacherController@logout');


Route::post('/teacher/login', 'TeacherController@login');


Route::Resource('/teacher', 'TeacherController');







//student Resource


Route::Resource('/student', 'StudentController');











//Teacher Resource

/*Route::group(['middleware' => 'teacher'], function () {
    Route::get('/teacher/home', 'TeacherController@home');
});*/



Route::Resource('/aboutschool', 'AboutSchoolController');


Route::Resource('/assignment', 'AssignmentController');


Route::Resource('/award', 'AwardController');




Route::Resource('/classdetail', 'ClassDetailController');


Route::Resource('/billing', 'BillingController');


Route::Resource('/classtest', 'ClassTestController');


Route::Resource('/section', 'SectionController');

Route::get('/examall', 'ExamController@index');

Route::get('/exam/uploadfile', 'ExamController@upload_file');

Route::view('/exam/manually', 'Admin.ExamManually');

Route::delete('/deleteall', 'ExamController@delete_all');

Route::post('/exam/upload', 'ExamController@upload_xls');

Route::Resource('/exam', 'ExamController');


Route::Resource('/expenses', 'ExpensesController');


Route::Resource('/governingboard', 'GoverningBoardController');


Route::Resource('/gallery', 'GalleryController');



Route::post('/images', 'ImageController@store');

Route::delete('/images/delete', 'ImageController@destroy');

Route::Resource('/library', 'LibraryController');


Route::Resource('/loan', 'LoanController');


Route::Resource('/notice', 'NoticeController');


Route::Resource('/payment', 'PaymentController');


Route::Resource('/schoolassest', 'SchoolAssestController');


Route::Resource('/studentbehaviour', 'StudentBehaviourController');



Route::Resource('/stuff', 'StuffController');

Route::Resource('/teacherattendence', 'TeacherAttendenceController');

here is my web.php file


Route::post('/images', 'ImageController@store');

Route::delete('/images/delete', 'ImageController@destroy');

but if i use /images i have been created for that also shows 404 error

Sinnbeck's avatar

That is indeed strange. i dont see any issues in the web.php

If you open developer tools (f12) in chrome (under network tab) and then run the uploadfile method. Does it the hit the right url ?

masumluf's avatar

it shows

Not Found
The requested resource /images was not found on this server.
masumluf's avatar

Nope it shows as following,

Request URL: http://127.0.0.1:8000/gallery
Request Method: POST
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8000
Referrer Policy: no-referrer-when-downgrade
masumluf's avatar

Yeah i did but i dont think it will be shown 404 error for csrf token

Please or to participate in this conversation.