php - Pass image data from form upload to a function to save -
i have upload form mulitple file attachments name="attachment[]"
i need pass uploaded file function in class handles saving of file (amongst other actions).
the function:
public function savefile($userid, $ticketid, $filetype, $filename, $filecontent) { // create directory $this->createdirectory($ticketid); $file = fopen(file_save_path . "/" . $ticketid . "/" . $filename, 'w'); fwrite($file, $filecontent); fclose($file); }
the loop sending function data
foreach($_files['attachment']['name'] $index => $value) { $fw->models->file->savefile( $si->input->session('bug/userdata/id'), $ticketid, '', $_files['attachment']['name'][$index], base64_encode($_files['attachment']['tmp_name'][$index])); }
as can see i've tried base64_encode, image "saved" corrupt when try open it.
thank you.
look @ http://www.tizag.com/phpt/fileupload.php seems missing few of finer details of saving upload. base64_encode($_files['attachment']['tmp_name'][$index])); not file
try print_r($_files) before doing array.
Comments
Post a Comment