CodeIgniter Forums
failed to upload image file and save data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: failed to upload image file and save data (/showthread.php?tid=26620)

Pages: 1 2 3 4


failed to upload image file and save data - El Forum - 01-19-2010

[eluser]theprodigy[/eluser]
that's enough Cestaz18. Thanks.


failed to upload image file and save data - El Forum - 01-19-2010

[eluser]maria clara[/eluser]
@ the prodigy,

sir, in our Upload.php in the Libraries shows this script in the data().
Code:
$file_data = $this->upload->data();

this script calls this in the Upload.php
Code:
function data()
    {
        return array (
                        'file_name'            => $this->file_name,
                        'file_type'            => $this->file_type,
                        'file_path'            => $this->upload_path,
                        'full_path'            => $this->upload_path.$this->file_name,
                        'raw_name'            => str_replace($this->file_ext, '', $this->file_name),
                        'orig_name'            => $this->orig_name,
                        'file_ext'            => $this->file_ext,
                        'file_size'            => $this->file_size,
                        'is_image'            => $this->is_image(),
                        'image_width'        => $this->image_width,
                        'image_height'        => $this->image_height,
                        'image_type'        => $this->image_type,
                        'image_size_str'    => $this->image_size_str,
                    );
    }



failed to upload image file and save data - El Forum - 01-19-2010

[eluser]cestaz18[/eluser]
[quote author="theprodigy" date="1263984035"]Please update your controller. In your post() method, I still see:

Quote:$fields = array(
"module_name"=>$this->input->post('module_name'),
"slug"=>$this->input->post('slug'),
"icon"=>$this->input->post('file_name'),
"report_file_name"=>$this->input->post('report_file_name'),
"sql_select"=>$this->input->post('sql_select'),
"sql_filter"=>$this->input->post('sql_filter'),
"sql_order"=>$this->input->post('sql_order')
);

In your view, I also only see:

Quote:<div class="infield">
&lt;?php echo form_open_multipart('at_reports/post');?&gt;
&lt;input type="file" name="userfile" class="tb" title="&lt;?=lang('icon');?&gt;"/&gt;
&lt;input type="submit" value="upload" /&gt;
&lt;!--&lt;/form&gt;--&gt;
&lt;!--&lt;input type="text" name="icon" class="tb" title="&lt;?=lang ('icon');?&gt;" /&gt;--&gt;
</div>

The controller part needs to be updated with the fact that you cannot retrieve the file name from the $this->input->post() method. It simply isn't there. You need to get the file name from the $file_data array.

In your view, it doesn't look like the form elements are all there, and you aren't closing your form tag (the close form tag is commented out, as is the icon input field). Am I not seeing the full form? Do you have other parts of the form being added on later?[/quote]



i'm little confuse of what ur telling..
"icon"=>$this->input->post('file_name'), ..in this code..i follow only wat u said a while a go..you compare it to our code and i copy wat u said to change..


in my view...
i already remove the comment in form closing tag...the same with icon input field..but the same error i got..no value has been save in my icon and file_name field in my database...only the other field has been succesfully save..

can u show me the code u want to tell??..tnx


failed to upload image file and save data - El Forum - 01-19-2010

[eluser]theprodigy[/eluser]
You need to get the file_name from your $file_data array like such:
Code:
$fields = array(
  “module_name”=>$this->input->post(‘module_name’),
  “slug”=>$this->input->post(‘slug’),
  “icon”=>$file_data['file_name'], // <--- use $file_data array, not $this->input->post()
  “report_file_name”=>$this->input->post(‘report_file_name’),
  “sql_select”=>$this->input->post(‘sql_select’),
  “sql_filter”=>$this->input->post(‘sql_filter’),
  “sql_order”=>$this->input->post(‘sql_order’)
);

you are currently trying to get it from $this->input->post(), and you can't do that. The rest of the fields are fine to get from $this->input->post(), you just can't get the file_name from it.


failed to upload image file and save data - El Forum - 01-19-2010

[eluser]cestaz18[/eluser]
[quote author="theprodigy" date="1263987495"]You need to get the file_name from your $file_data array like such:
Code:
$fields = array(
  “module_name”=>$this->input->post(‘module_name’),
  “slug”=>$this->input->post(‘slug’),
  “icon”=>$file_data['file_name'], // <--- use $file_data array, not $this->input->post()
  “report_file_name”=>$this->input->post(‘report_file_name’),
  “sql_select”=>$this->input->post(‘sql_select’),
  “sql_filter”=>$this->input->post(‘sql_filter’),
  “sql_order”=>$this->input->post(‘sql_order’)
);

you are currently trying to get it from $this->input->post(), and you can't do that. The rest of the fields are fine to get from $this->input->post(), you just can't get the file_name from it.[/quote]

uhmmm...=(

it doesnt work..

actually i use also that code before..

but it doesnt work..

hahayz..watz the problem..????


failed to upload image file and save data - El Forum - 01-20-2010

[eluser]theprodigy[/eluser]
is the file actually being uploaded? Have you checked the directory where you are telling it to upload? Are the files there? If not, are the permissions set correctly?

Just for debugging purposes, try changing:
Code:
$this->upload->do_upload();
to:
Code:
print_r($this->upload->do_upload());



failed to upload image file and save data - El Forum - 01-20-2010

[eluser]cestaz18[/eluser]
[quote author="theprodigy" date="1263988916"]is the file actually being uploaded? Have you checked the directory where you are telling it to upload? Are the files there? If not, are the permissions set correctly?

Just for debugging purposes, try changing:
Code:
$this->upload->do_upload();
to:
Code:
print_r($this->upload->do_upload());
[/quote]


yes i have been checked already my directory folder where the file wil be upload..i dont see any image upload ..

i try ur debugging code...

no error found ..

succesfully save..but no value again in icon and file_name field in database...


failed to upload image file and save data - El Forum - 01-20-2010

[eluser]theprodigy[/eluser]
ok, try this right after your call to $this->upload->do_upload();
Code:
echo $this->upload->display_errors();

so, you will end up with:

Code:
$this->upload->do_upload();
echo $this->upload->display_errors(); // <--- add it right here
$file_data = $this->upload->data();



failed to upload image file and save data - El Forum - 01-20-2010

[eluser]cestaz18[/eluser]
ok i got the error...

this show me in my firebug...

what is telling i did not select a file to upload???but i select a file before i upload it..hmmm..i'm confuse??



Code:
<p>You did not select a file to upload.</p><br />
<b>Fatal error</b>:  ob_start() [&lt;a href='ref.outcontrol'&gt;ref.outcontrol&lt;/a&gt;]: Cannot use output buffering in output buffering display handlers in <b>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\comunion\system\libraries\Exceptions.php</b> on line <b>160</b><br />