(PS: Latest Progress-& amp; gt; I failed to call the File Upload class library, that is, I $ this-& amp; gt; load-& amp; gt; library (& #039; upload & #039;, $ cofig) The problem occurs here. You can echo a sentence before this sentence, and then echo won't work. I don't know if it's swollen. I'm so kind ...(
PS:Latest Progress->
I failed to call the File upload class library. That is to say, I have a problem with $ this-> load-> library ('upload', $ cofig). I can echo a sentence before this sentence, echo won't work.. I don't know if it's swollen. I'm so kind ...)
Example: It was okay when I uploaded the file yesterday. This happened when I used it today.
When printing $ _ FILES, all the file data is available, but there is no temporary file in the temporary directory.
The configuration is as follows:
$upload_cofig['upload_path'] = './uploads/sourse_message/';$upload_cofig['allowed_types'] = 'gif|jpg|png|jpeg';$upload_cofig['max_size'] = '100000';$upload_cofig['max_width'] = '1024';
In addition, I also wrote enctype = "multipart/form-data" in form"
This is how to upload files.
public function upload_file($filename){ $upload_cofig['upload_path'] = './uploads/sourse_message/'; $upload_cofig['allowed_types'] = 'gif|jpg|png|jpeg'; $upload_cofig['max_size'] = '100000'; $upload_cofig['max_width'] = '1024'; $upload_cofig['file_name'] = date("Y-m-d H:i:s",time()).rand(1000,9999); $this->load->library('upload',$upload_cofig); if (!file_exists($upload_cofig['upload_path'])) { @mkdir($upload_cofig['upload_path']); chmod($upload_cofig['upload_path'], 0777); } if (!$this->upload->do_upload($filename)) { $result = array('flag'=>0,'msg' => $this->upload->display_errors()); }else{ $data=$this->upload->data(); $result = array('flag'=>1,'msg'=>substr($upload_cofig['upload_path'], 1) . $data['file_name']); } return $result; }
Add: OnThe same file upload test code is written locally.The result is stillPrint dataBut under the Temporary FolderNo temporary filesThis isWhat ghosts? (I have also tested any properties including file hiding, and it won't work.)
Reply content:
(PS:Latest Progress->I failed to call the File upload class library. That is to say, I have a problem with $ this-> load-> library ('upload', $ cofig). I can echo a sentence before this sentence, echo won't work.. I don't know if it's swollen. I'm so kind ...)
Example: It was okay when I uploaded the file yesterday. This happened when I used it today.
When printing $ _ FILES, all the file data is available, but there is no temporary file in the temporary directory.
The configuration is as follows:
$upload_cofig['upload_path'] = './uploads/sourse_message/';$upload_cofig['allowed_types'] = 'gif|jpg|png|jpeg';$upload_cofig['max_size'] = '100000';$upload_cofig['max_width'] = '1024';
In addition, I also wrote enctype = "multipart/form-data" in form"
This is how to upload files.
public function upload_file($filename){ $upload_cofig['upload_path'] = './uploads/sourse_message/'; $upload_cofig['allowed_types'] = 'gif|jpg|png|jpeg'; $upload_cofig['max_size'] = '100000'; $upload_cofig['max_width'] = '1024'; $upload_cofig['file_name'] = date("Y-m-d H:i:s",time()).rand(1000,9999); $this->load->library('upload',$upload_cofig); if (!file_exists($upload_cofig['upload_path'])) { @mkdir($upload_cofig['upload_path']); chmod($upload_cofig['upload_path'], 0777); } if (!$this->upload->do_upload($filename)) { $result = array('flag'=>0,'msg' => $this->upload->display_errors()); }else{ $data=$this->upload->data(); $result = array('flag'=>1,'msg'=>substr($upload_cofig['upload_path'], 1) . $data['file_name']); } return $result; }
Add: OnThe same file upload test code is written locally.The result is stillPrint dataBut under the Temporary FolderNo temporary filesThis isWhat ghosts? (I have also tested any properties including file hiding, and it won't work.)
CI: Chinese people, good people, few posts, no response for half a day sang Xin
What is the size of the uploaded file? What is the size limit of the File Uploaded By the Server post? Have you found out all of this?
There should be an error message. The temporary file seems to be visible in Windows, and I cannot find it in linux tmp.
Check whether an error occurred while saving the file.
1. In the first line of Action, Print $ _ PSOT first. First, check whether the file is submitted. If the file is not submitted, it is basically a front-end problem. Otherwise, check 2.
2, @ mkdir ($ upload_cofig ['upload _ path']); this sentence is useless because if you fail to create a directory, no error will be reported, the program will continue. If there is no upload_path, the upload is not successful!
3. the parameter of the $ this-> upload-> do_upload () method is the name of the file domain. However, I don't know what your $ filename is!
4. Print $ this-> upload-> display_errors () to view the specific error message!
The above four points can basically determine the problem!
My code:
/** Image Upload */protected function img_upload ($ image = '') {$ dirname = date (" Ymd "); $ config ['upload _ path'] = '.. /public/images /'. $ dirname. '/'; $ pathStr = $ config ['upload _ path']; // create a folder if (! File_exists ($ pathStr) {if (! Mkdir ($ pathStr, 0777, true) {$ error = "mkdir failed"; $ code = '0'; $ res = array ('0' => $ code, '1' => $ error); return $ res; }}$ config ['allowed _ types '] = 'jpg | jpeg '; $ config ['file _ name'] = time (). rand (1, 10000); $ config ['max _ size'] = 1024; $ this-> load-> library ('upload', $ config ); $ this-> upload-> initialize ($ config); if (! $ This-> upload-> do_upload ($ image) {$ error = $ this-> upload-> display_errors (); $ code = '0 '; $ res = array ('0' => $ code, '1' => $ error); return $ res ;} else {$ file_name = $ this-> upload-> data ('file _ name'); $ url = "/public/images /". $ dirname. '/'. $ file_name; $ code = '1'; $ res = array ('0' => $ code, '1' => $ url); return $ res ;}}