I am using Blueimp.jquery file-upload for file uploads. My app is also under Laravel 4 framework and I have an error on uploading file.
The error returned by this API in Firefox and Chrome is:
Error: Method Not Allowed
I think the error comes with routing on Laravel because this is what I found on Firebug dev console:
{"error":{"type":"Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException","message":"","file":"C:\\xampp\\htdocs\\digisells\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteCollection.php","line":210}}
This is the form code:
{{ Form::open(['route'=>'image.store','id'=>'fileupload','files'=>true]) }}
<div class="col-md-12">
<div class="container">
<!-- file upload -->
<!-- <form id="fileupload" action="file-upload/product-images" method="POST" enctype="multipart/form-data"> -->
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<noscript><input type="hidden" name="redirect" value="http://blueimp.github.io/jQuery-File-Upload/"></noscript>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-md-7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="thumbnail" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-md-5 fileupload-progress fade">
<!-- The global progress bar -->
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-success" style="width:0%;"></div>
</div>
<!-- The extended global progress state -->
<div class="progress-extended"> </div>
</div>
</div>
<!-- The table listing the files available for upload/download -->
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
<!-- </form> -->
</div>
</div>
{{ Form::close() }}
This is the routes code for the form:
Route::resource('image', 'ImageUploadController');
And inside the ImageUploadController I have:
public function store()
{
$file = Input::file('thumbnail');
$file = move(public_path().'/product/images/temp/', $file=>getClientOriginaLName());
}
If the routing is the issue, How could I register these routes on my routes file? I mean what verbs do I have to use and the codes inside of each functions? Or are there some other possible solutions to this? Thanks.