Welcome Guest, Not a member yet? Register   Sign In
Move file error
#1

(This post was last modified: 07-05-2022, 06:49 AM by pippuccio76.)

Hi i have this error when i move a file:

CodeIgniter\HTTP\Exceptions\HTTPException Could not move file php6d2QrM to /var/www/mysite/uploaded/abc/xpz/documenti_centri/3/documenti/ ()

thi is the code :
PHP Code:
if (($this->request->getMethod() === 'post')){
            
            $validation 
=  \Config\Services::validation();
            
            $rules
=
            [
                                    'id_centri'=>[
                                                'label'=>'Id centri',
                                                'rules'=>'required|trim|min_length[0]|max_length[11]',
                                                'errors'=>[
                                                            'min_length'=>'Lunghezza minima Id centri 0 caratteri',  
                                                            
'max_length'=>'Lunghezza massima Id centri 11 caratteri',
                                                            'required'=>'Id centri obbligatorio'
                                                          ]
                                                ],
                                    'nome'=>[
                                                'label'=>'Nome',
                                                'rules'=>'required|trim|min_length[0]|max_length[400]|validateUniqueName[nome]',
                                                'errors'=>[
                                                            'min_length'=>'Lunghezza minima Nome 0 caratteri',  
                                                            
'max_length'=>'Lunghezza massima Nome 400 caratteri',
                                                            'required'=>'Nome obbligatorio',
                                                            'validateUniqueName' => 'Nome non deve essere già utilizzato'
                                                          ]
                                                ],
                                    'pdf'=>[      
                                                
'label'=>'Pdf',
                                                'rules'=>'uploaded[file_pdf]|max_size[file_pdf,4024]|ext_in[file_pdf,pdf]',
                                                'errors'=>[
                                                            'uploaded'=>'Problemi caricamento file',
                                                            'ext_in'=>'Estensione file non corretta puoi caricare solamente file PDF',
                                                            'max_size'=>'File troppo pesante'
                                                          ]
                                                ],
                                  ];

            if($this->validate($rules)){



                //recupero le informazioni del file
                $file_pdf $this->request->getFile('file_pdf');



                    //cartella in cui mettere il file
                    $cartella_file FCPATH 'uploaded/abc/xpz/documenti_centri/'.session()->get('centri_id').'/documenti';

                    //lo trasferisco nella cartella uploaded
                    if($file_pdf->move($cartella_file)){ 
The same code work in local but not in server 
Why ?
Reply
#2

The error message is lost.

Can you try this code in your server?
Code:
--- a/system/HTTP/Files/UploadedFile.php
+++ b/system/HTTP/Files/UploadedFile.php
@@ -143,8 +143,7 @@ class UploadedFile extends File implements UploadedFileInterface
        try {
            $this->hasMoved = move_uploaded_file($this->path, $destination);
        } catch (Exception $e) {
-            $error  = error_get_last();
-            $message = strip_tags($error['message'] ?? '');
+            $message = (string) $e;

            throw HTTPException::forMoveFailed(basename($this->path), $targetPath, $message);
        }
Reply




Theme © iAndrew 2016 - Forum software by © MyBB