CI upload file demo not working? |
I am using codeigniter 2.2.6 for my server (I am a newbie in CI), when I tried to make the upload file demo work, but nothing happened when I clicked on the submit button.
Here is the user guide that I followed: http://www.codeigniter.com/userguide2/li...ading.html the view file: PHP Code: <html> the controller: PHP Code: <?php I can see the browse and submit button, after I select a file, the file name is correctly displayed but when I click on submit, nothing happens, it looks like that the submit click is not handled. As you can see, I set 3 echo "step ." to follow the flow, but none of them get printed, I don't know why. Could anyone help? please explain me the logic behind that button click handling.
I guess the following code has some pbs:
<?php echo form_open_multipart('upload/do_upload');?> the function do_upload is not called at all, how should it be used?
OK, I found the problem, apparently there is a problem of
<?php echo form_open_multipart('upload/do_upload');?> It generate this wrong url: <form enctype="multipart/form-data" accept-charset="utf-8" method="post" action="http://::1/upload/do_upload"> <input type="file" size="20" name="userfile"> <br> <br> <input type="submit" value="upload"> </form> I changed the action="http://::1/upload/do_upload" to action="http://localhost/upload/do_upload" and it works. Could anyone explain why <?php echo form_open_multipart('upload/do_upload');?> generates the wrong url?
You probably left the $config['base_url'] setting blank (in application/config/config.php). Then, CI is best-guessing it. I think your hosts file (in Windows/System32/Drivers/Etc) there is no reference to localhost, but only to ::1.
The easiest way to solve the problem is assigning the right value to $config['base_url']. In your case: PHP Code: $config['base_url'] = 'http://localhost/'; (03-20-2016, 01:39 AM)seaguest Wrote: Indeed it is empty, because I have removed the index.php in the url path. index.php in your URIs has nothing to do with the base_url setting. Also, upgrade to the latest 3.0.x version, now - you wouldn't have this problem with it. 2.x is unsupported, there's no point in trying to teach yourself in it. |
Welcome Guest, Not a member yet? Register Sign In |