I use CodeIgniter to write image upload form. Earlier I had a similar code to work on another site. Currently, the code for receiving an image with multiple data / data forms does not work. When configuring the server / script, I got errors, such as the wrong file path, inconsistent mime types, but now I get nothing.
The code below returns: "ABC" and crashing before "D" without error.
If I change 'photo_filedata' to 'photo_filedata2', I get a more useful error: "ABCD You did not select a file to upload."
I have a complete loss to debug this, since I do not receive errors from the server at all.
Does anyone know what could happen?
Server: WAMP, running on Windows 7. Has an existing project that downloads files without problems.
function upload_photo() { echo "A"; $config['upload_path'] = './images/uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['file_name'] = 'photo_' . substr(md5(time()), 0, 16); $config['max_size'] = 2000; $config['max_width'] = 0; $config['max_height'] = 0; echo "B"; $this->load->library('upload', $config); echo "C"; $result = $this->upload->do_upload('photo_filedata'); echo "D"; if (!$result) { $error = $this->upload->display_errors(); $data = false; } else { $error = false; $data = $this->upload->data(); } $this->load->view('home-photo-upload', array('error' => $error, 'data' => $data)); }
source share