Zip uplaod - El Forum - 04-25-2013
[eluser]boytun[/eluser]
Hello
I want uplode a . zip file but I can not:
I get this error:
Quote:The filetype you are attempting to upload is not allowed.
the controller:
Code: <?php
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = '../files/';
$config['allowed_types'] = 'gif|jpg|png|txt|zip';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
?>
the upload form view:
Code: <html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>
Zip uplaod - El Forum - 04-25-2013
[eluser]boytun[/eluser]
thank to InsiteFX
[quote author="InsiteFX" date="1331153873"]mimes.php
Code: 'zip' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream', 'application/x-compress', 'application/x-compressed', 'multipart/x-zip'),
'rar' => ('application/rar', 'application/x-rar', 'application/x-rar-compressed', 'application/x-compressed', 'application/octet-stream'),
Code: $up_config['upload_path'] = './assets/img/uploads/';
$up_config['allowed_types'] = 'zip|rar|txt';
$this->load->library('upload',$up_config);
upload file data:
Code: Array ( [file_name] => country_road.zip
[file_type] => text/plain
[file_path] => public_html/mhphoto/assets/img/uploads/
[full_path] => public_html/mhphoto/assets/img/uploads/country_road.zip
[raw_name] => country_road
[orig_name] =>
[client_name] => country_road.zip
[file_ext] => .zip
[file_size] => 403888
[is_image] =>
[image_width] =>
[image_height] =>
[image_type] =>
[image_size_str] => )
You may also need to download the 3.0 Dev which I belive has fixed the upload problems...
[/quote]
|