Welcome Guest, Not a member yet? Register   Sign In
failed to upload image file and save data
#10

[eluser]theprodigy[/eluser]
you might not be getting an error, because it may not be going into your
Code:
if ($this->upload->do_upload()){ ... }

statement. If it doesn't go into that, then it won't even try to save.

Don't get me wrong, that is the correct way of doing it, just make sure that the file is actually getting uploaded (check the folder, if no files are in there, check the write permissions of that folder. Make sure your website can write to that folder)

Also, the following code will not work.
Code:
$fields = array(
                    "module_name",
                    "slug",
                    //"icon"=>$file_data['file_name'],    
                    "icon"=>$file_name,
                    //'icon' => $file_name,                        
                    "report_file_name",
                    "sql_select",
                    "sql_filter",
                    "sql_order"
                );
                            
            

[b]foreach ($fields as $field)
{
    if (isset($_POST[$field])) $dt[$field] = $this->input->post($field);
}
[/b]                    
$item = $this->input->post("item");
$rows = $this->input->post("row0");

$data['item'] = $this->Reports->save($dt,$item,$rows);

Your foreach loop will loop over that array just fine, but your check to see if it isset in the $_POST array will fail when it comes to the
Quote:"icon"=>$file_name,
part, because "icon" does not exist in the $_POST array. Why don't you just manually set the fields in the $fields array, like you are for the "icon" field.

Code:
$fields = array(
                    "module_name"=>$this->input->post('module_name'),
                    "slug"=>$this->input->post('slug'),
                    "icon"=>$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')
                );

and just get rid of the foreach loop and pass in the $fields array instead.
Or loop through the fields array like you are, but unset any elements that equal false, to get rid of any fields that weren't passed in.


Messages In This Thread
failed to upload image file and save data - by El Forum - 01-18-2010, 09:41 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 09:53 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 09:57 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 10:05 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 10:10 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 11:23 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 11:30 PM
failed to upload image file and save data - by El Forum - 01-18-2010, 11:35 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 12:09 AM
failed to upload image file and save data - by El Forum - 01-19-2010, 12:22 AM
failed to upload image file and save data - by El Forum - 01-19-2010, 03:34 AM
failed to upload image file and save data - by El Forum - 01-19-2010, 06:50 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 07:23 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 07:39 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 07:43 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:08 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:17 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:22 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:33 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:37 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:43 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:46 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:48 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:50 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:51 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 08:56 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 10:40 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:04 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:06 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:07 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:11 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:18 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:26 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:38 PM
failed to upload image file and save data - by El Forum - 01-19-2010, 11:56 PM
failed to upload image file and save data - by El Forum - 01-20-2010, 12:01 AM
failed to upload image file and save data - by El Forum - 01-20-2010, 12:09 AM
failed to upload image file and save data - by El Forum - 01-20-2010, 12:17 AM
failed to upload image file and save data - by El Forum - 01-20-2010, 12:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB