So I've built a wizard using php, and one of the forms asks for the user to upload an image.
I've built everything out already, the only problem is I have to be able to say, in one of my if-statements, if the form was submitted using jquery's submit() method.
So here is the code that submit's the form in jquery after the user has selected an image.
var initUpload = function(){
$('.filebutton').change(function(e){
$("form").submit();
});
};
And this is how my if statement looks.
if($this->input->post('back')){
//Tells me that the user clicked on the back button, and to go back 1 step in the wizard.
}else if(???){
//This is where I would like to say: if form was submitted with jquery.
}else{
//Else the user just clicked "next" and to continue normally.
}
What I already know:
Using $this->input->post('back')
I can check if the form was submitted using a button with the value
of BACK. I've var_dumped $this->input->post()
but it only returns the values of the input field.
As in above comment i was requested to post my comment as answer so here you go
if($this->input->post('back')){
//Tells me that the user clicked on the back button, and to go back 1 step in the wizard.
}else if($_FILES['your_image_filed_name']){
//This is where I would like to say: if form was submitted with jquery.
//you can use codeigniter's built in Upload libraray which v easy
}else{
//Else the user just clicked "next" and to continue normally.
}
Here is the upload
code have a look at
$config_logo_image = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => UPLOAD_PATH,//root path for image
'max_size' => 2000,
);
$this->load->library('upload', $config_logo_image );
if($this->upload->do_upload('your_image_filed_name')){
$logo_image_data = $this->upload->data();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With