Part of the EllisLab Network
   
 
Help with file upload
Posted: 02 July 2009 08:37 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  133
Joined  04-02-2009

how do you receive a file that comes from a form??... i cant find an example at the user guide… help please

Profile
 
 
Posted: 02 July 2009 08:45 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2690
Joined  05-18-2008

Really? Cause I find the page on the File uploading class to cover everything you need raspberry

 Signature 

I’m building a Project Management System for my 3rd year Uni project, Sign up to the beta
Track my progress | Post of the day: UI Designs
Get full auto complete support for CodeIgniter in Eclipse

Profile
 
 
Posted: 02 July 2009 09:10 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  133
Joined  04-02-2009

Haha, ok.. I guess I didnt know where to look… one question though.. Ive no experience in this… can the form be the same as a form with regular values that are being retrived using
$this->input->post(‘sometext’);???

I mean
My form has a bunch of input texts and one input file… is there any way to so it all with just one form??

Profile
 
 
Posted: 02 July 2009 10:02 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  133
Joined  04-02-2009
$config['upload_path'] = './uploads/';
        
$config['allowed_types'] = 'gif|txt|png';
        
$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());
            
$asiarchivo="No file was uploaded";
            
print_r($error);
        
}

I changed it to upload txt files but it always gives me this error
“The filetype you are attempting to upload is not allowed.”

Profile
 
 
Posted: 02 July 2009 11:19 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2264
Joined  07-30-2007
<pre>
<?php print_r($this->upload->data()); ?>
</pre>

That will let you know what mime type your server is interpreting for that file, then check the mimetypes config file to make sure the extension is one of the allowed extensions for that mime type.

 Signature 

Become a fan of the CodeIgniter Cookbook (estimated: Fall 2010).

Follow me on twitter here.
MichaelWales.com | MichaelWales.info

Profile
 
 
Posted: 02 July 2009 12:43 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  133
Joined  04-02-2009

Ok.. txt is working now….. never really figured out why it wasnt working… but pdfs arent working now…
on mimes.php I have

'pdf'    =>    array('application/pdf', 'application/x-download'),

on my config I have

$config['allowed_types'] = 'txt|png|doc|docx|xls|xlsx|pdf|mp3|wma|wmv|gif|jpg|png';
        
$config['max_size']    = '999999999';
        
$config['max_width']  = '999999999';
        
$config['max_height']  = '999999999';
        
$this->load->library('upload', $config);

and

$error = array('error' => $this->upload->display_errors());
            
print_r($this->upload->data());
            echo
"<br />";
            
print_r($error);

printed out

Array ( [file_name] => PDFlib-Lite-license.pdf [file_type] => application/pdf [file_path] => /var/www/vhosts/----/httpdocs/----/ [full_path] => /var/www/vhosts/----/httpdocs/----/PDFlib-Lite-license.pdf [raw_name] => PDFlib-Lite-license [orig_name] => [file_ext] => .pdf [file_size] => 30.29 [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => )
Array (
[error] =>

The filetype you are attempting to upload is not allowed
Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 115026 Total Logged-in Users: 64
Total Topics: 122461 Total Anonymous Users: 2
Total Replies: 647368 Total Guests: 454
Total Posts: 769829    
Members ( View Memberlist )