uploading zip files in codeigniter won't work -
i have created helper requires parameters , should upload file, function works images not zip files. searched on google , added my_upload.php -> http://codeigniter.com/bug_tracker/bug/6780/
however still have problem used print_r display array of uploaded files, image fine zip array empty:
array ( [file_name] => [file_type] => [file_path] => [full_path] => [raw_name] => [orig_name] => [file_ext] => [file_size] => [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => ) array ( [file_name] => 2385b959279b5e3cd451fee54273512c.png [file_type] => image/png [file_path] => i:/wamp/www/e-commerce/sources/images/ [full_path] => i:/wamp/www/e-commerce/sources/images/2385b959279b5e3cd451fee54273512c.png [raw_name] => 2385b959279b5e3cd451fee54273512c [orig_name] => 1269770869_art_artdesigner.lv_.png [file_ext] => .png [file_size] => 15.43 [is_image] => 1 [image_width] => 113 [image_height] => 128 [image_type] => png [image_size_str] => width="113" height="128" )
this function helper
function multiple_upload($name = 'userfile', $upload_dir = 'sources/images/', $allowed_types = 'gif|jpg|jpeg|jpe|png', $size) { $ci =& get_instance(); $config['upload_path'] = realpath($upload_dir); $config['allowed_types'] = $allowed_types; $config['max_size'] = $size; $config['overwrite'] = false; $config['encrypt_name'] = true; $ffiles = $ci->upload->data(); echo "<pre>"; print_r($ffiles); echo "</pre>"; $ci->upload->initialize($config); $errors = false; if(!$ci->upload->do_upload($name))://i believe causing problem i'm new codeigniter no idea errors $errors = true; else: // build file array uploaded files $files = $ci->upload->data(); endif; // there errors, have delete uploaded files if($errors): @unlink($files['full_path']); return false; else: return $files; endif; }//end of multiple_upload()
and code in controller
if(!$s_thumb = multiple_upload('small_thumb', 'sources/images/', 'gif|jpg|jpeg|jpe|png', 1024)): //http://www.matisse.net/bitcalc/ $data['feedback'] = '<div class="error">could not upload small thumbnail!</div>'; $error = true; endif; if(!$main_file = multiple_upload('main_file', 'sources/items/', 'zip', 307200)): $data['feedback'] = '<div class="error">could not upload main file!</div>'; $error = true; endif;
found solution -> codeigniter.com/forums/viewthread/149027 adding force-download allowed mime types
Comments
Post a Comment