do_upload() returns true but no file is uploaded. CI 2.0.2 |
[eluser]tinflute[/eluser]
http://stackoverflow.com/questions/10503...black-hole I am trying to upload a single file in CodeIgniter 2.0.2 in a normal way. The do_upload() function returns true but no file appears in the directory. Directory permissions appear to be fine (after running other diagnostics not shown in code below), so it makes no sense that the file is not appearing in the upload directory. Here is controller and view code, adapted straight from the CI docs. Controller: Code: function do_upload_sql(){ Code: <p>Select the backup file</p>
[eluser]sailorob[/eluser]
Have you tried just running a manual fwrite to your BACKUP_DIR?
[eluser]tinflute[/eluser]
Ok, I borrowed the code below from php.net to test if fwrite works. The function reports success, but yet again no file appears!! So this suggest that it has to be some kind of path issue. But the same path string is being used successfully for mkdir(). So then it should be a permissions issue, but that has been ruled out by the fwrite test. Weird Code: function file_write_test($filename = '_no.txt',$content = 'hello world'){
[eluser]sailorob[/eluser]
Whats the value of BACKUP_DIR? And were you appending to the $filename variable you passed into that above function? Not to state the obvious but is it a full system path? Like "/var/www/website/files/"? If not, your file is just going to be written the path local to where your script is running, less you've set a chdir().
[eluser]tinflute[/eluser]
the file i passed into the $filename variable was the complete path so BACKUP_DIR.$userfile and this is what got echoed to the browser: Success, wrote (hello world) to file (C:/backup_database/db_pk_v4.backup)
[eluser]tinflute[/eluser]
AHA! I changed Code: $config['allowed_types'] = '*'; So this means it has to do with the mime types. My application/config/mimes.php has been extended with an entry for Code: 'backup'=>'application/octet-stream', I understand that CI 2.1 introduced a bug in do_upload() related to mime types (will look for the thread on this). I'm using 2.0.2. Do I need to change something in core do_upload() or is my mime extension defined incorrectly? Thanks for the help so far!!
[eluser]InsiteFX[/eluser]
If running on Windows: Right click the folder, click properties, open security tab, edit the users (or your computer name) tick the modify(I tick all). It works, I also use php and save it to htdocs, it works without the need of running as admin, which wont do to folders! |
Welcome Guest, Not a member yet? Register Sign In |