I am not familiar with this problem I am facing.. I would like to upload image file through ajax & php
so far I have done these: HTML:
<input type="file" name="file" id="file" class="inputfile">
<label for="file">Choose a file</label>
ajax:
jQuery(document).ready(function($) {
var data = {
business_name: $('#business_name').val(),
business_country: $('#business-country').val(),
business_region: $('#business-region').val(),
business_phone: $('#business_phone').val(),
//business_image: $('#image-data').val(),
business_image: $('#file').val(),
token: $('#token').val()
}
$.ajax({
type: "POST",
data: data,
url: "index.php?route=account/profile/savetoken=" + data.token,
success: function(data) {
$("#containerAlertMessages").html("<div id='alertMessages' class='alert alert-success'><strong>Success!</strong> Your profile has been successfully saved!</div>");
}
});
});
I could get the path name of the image and store it to database.. But I could not upload the image on e specific folder..
I am using MVC model like openCart.. Actually I got the structure of OC, and building a dashboard from it..
Is there any way of using the tools already OC have like:
$this->load->model('tool/image');
otherwise, how could I upload images? serialize the form or something?
please be specific as possible so I could understand!
thanks in advance!