Codeigniter do_upload not responding on production server

I’ve cracked in the last hour to solve this problem. I am completely new to Codeigniter.

I made a page where certain file types will be loaded. It works great in my local development, but not in production. It will not pass the do_upload () function. Nothing is displayed outside of this.

$path = 'uploads'; echo 'path: '. $path .' <br>'; //-- config for uplaod -- $configUpdload['upload_path'] = $path ; $configUpdload['allowed_types'] = 'gif|jpg|png|xls|xlsx|pdf'; $configUpdload['max_size'] = '4000'; //size in kilobytes $configUpdload['encrypt_name'] = TRUE; //-- load upload library -- $this->load->library('upload'); $this->upload->initialize($configUpdload); if ($_FILES['fileref']['name']!="") { ini_set('display_errors', true); error_reporting(E_ALL); echo 'uploadAttachment<br>'; $uploaded = $this->upload->do_upload("fileref"); echo 'uploaded: '. $uploaded . '<br>'; if ($uploaded == true) { echo 'uploaded data<br>'; $inputUp = $this->upload->data(); echo 'data: '. print_r($inputUp,true) . '<br>'; $uploadInput['orig_name'] = $inputUp['orig_name']; $uploadInput['enc_name'] = $inputUp['file_name']; $uploadInput['extension'] = $inputUp['file_ext']; echo 'uploaded true<br>'; }else{ die($this->upload->display_errors()); } } 

I tried changing the upload_path to an existing folder, it shows "The upload path is not valid." So do_upload () is working correctly?

The permission of the download folder is 777.

I also tried using the absolute path, but still not show anything. do_upload ().

Or something related to the server?

Does anyone know what is going on? Thank you very much.

Thanks.

[edit1]

Nothing in the server error log and regular log. I also set $ config ['log_threshold'] = 4; There is no error log.

[edit2]

Production Server - third-party web hosting for Linux. I tried php_info () and tracked everything related to loading.

 file_uploads On On max_file_uploads 20 20 pload_max_filesize 30M 30M upload_tmp_dir /tmp/ /tmp/ suhosin.upload.disallow_binary 0 0 suhosin.upload.disallow_elf 1 1 suhosin.upload.max_uploads 25 25 suhosin.upload.remove_binary 0 0 suhosin.upload.verification_script no value 

I also tried to reduce the file size $ configUpdload ['max_size'] = '10'; but after do_upload () there is no message yet.

[Edit3] My folder structure:

 public_html/gtapp/ public_html/gtapp/csystem/ <- is system folder public_html/gtapp/v1/ <- is application folder public_html/gtapp/media/ public_html/gtapp/uploads/ public_html/gtapp/license.txt 

In config.php:

 $config['base_url'] = 'http://www.mydomain.com/gtapp/ 

In index.php:

 $application_folder = 'v1'; 

when I do APPPATH . 'uploads'; APPPATH . 'uploads'; before the code above:

 uploadAttachment path: v1/uploads uploaded: The upload path does not appear to be valid. 

I tried $path = $_SERVER['DOCUMENT_ROOT'] . '/gtapp/uploads'; $path = $_SERVER['DOCUMENT_ROOT'] . '/gtapp/uploads'; It just shows:

 uploadAttachment path: /home/user/domains/mydomain.com/public_html/gtapp/uploads 

Sorry, I know this is very simple. Naked with me please :)

[Edit4]

I made a crude version of my own PHP loading codes, and it works. I do not think this is a server problem. Below is the code:

 $name = 'fileref'; $upload_path = './uploads/'; $allowed_types = array("jpg", "jpeg", "gif", "png", "xls", "xlsx", "pdf"); $extension = end(explode(".", $_FILES[$name]["name"])); $max_size = '4000'; if ($_FILES['fileref']['name']!="") { if ((($_FILES[$name]["type"] == "image/gif") || ($_FILES[$name]["type"] == "image/jpeg") || ($_FILES[$name]["type"] == "image/pjpeg") || ($_FILES[$name]["type"] == "image/png") || ($_FILES[$name]["type"] == "image/x-png") || ($_FILES[$name]["type"] == "application/excel") || ($_FILES[$name]["type"] == "application/vnd.ms-excel") || ($_FILES[$name]["type"] == "application/msexcel") || ($_FILES[$name]["type"] == "application/pdf") || ($_FILES[$name]["type"] == "application/x-download")) && (round($_FILES[$name]["size"]/1024,2) < $max_size ) && in_array($extension, $allowed_types)) { if ($_FILES[$name]["error"] > 0) { echo $_FILES[$name]["error"]); } else { $uploadInput['orig_name'] = $_FILES[$name]["name"]; $uploadInput['enc_name'] = sha1($_FILES[$name]["name"]); $uploadInput['extension'] = $_FILES[$name]["type"]; $moved = move_uploaded_file($_FILES[$name]["tmp_name"], $upload_path . $uploadInput['enc_name'] . '.' . $extension); if($moved) echo 'success'; else echo 'fail'; } } } 
+4
source share
2 answers

I had a similar problem with CI and trying to verify the existence of files outside the application folder, and found that CI has this one enviromental veriable reserved for itself. APPPATH, it finds the main folder in which CI is located, from the index.php level, where you have the application and the system folder. Therefore, if you try to replace $configUpdload['upload_path'] = './uploads' ; on $configUpdload['upload_path'] = APPPATH.'uploads';

You may encounter a lot of luck.

0
source

I had this problem and all I did was change the following:

Edit:

 $path = 'uploads'; $configUpdload['upload_path'] = $path ; 

To:

 $path = './uploads'; $configUpdload['upload_path'] = $path; 

Or simply:

 $configUpdload['upload_path'] = './uploads'; 
0
source

Source: https://habr.com/ru/post/1433196/


All Articles