move_uploaded_file failed to open stream: No such file or directory

0

When I send a photo to update the profile on the system, it returns the following fault: move_uploaded_file (/isequi/public/assets/img/user_pic/062701-20160807-suicida.jpg):  failed to open stream: No such file or directory in C: \ xampp \ htdocs \ isequi \ sys \ class \ user.php

The environment for testing is windows 7 with xampp.

Code used:

$this->picName = basename($_FILES['userPicture']['name']); 
        $this->picExtension = pathinfo($this->picName, PATHINFO_EXTENSION); 
        $this->picSize = round($_FILES['userPicture']['size'] / 1000); 

        if($this->picSize == 0) {
            $functions -> generateJsonMsg('selectPicture', null, null, null, $message->message['selectPicture']);
        }
        if($this->picSize > 100)    {
            $functions -> generateJsonMsg('fileIsTooLarge', null, null, null, $message->message['fileIsTooLarge']);
        }
        $functions -> isInArray($this->picExtension, $this->arrayPictureExtensionPermitted, 'extensionNotAllowed', $message->message['extensionNotAllowed']);   

        $this->picName = date('sih-Ymd').'-'.$this->picName;
        $this->picNameDirectory = '/webpage/public/assets/img/user_pic/'.$this->picName;

        if(move_uploaded_file($_FILES['userPicture']['tmp_name'], $this->picNameDirectory)) {
            try   {
                $this->conn = parent::getconnection();  
                $this->pQuery = $this->conn->prepare(   'update user_detail '.
                                                        'set ud_picture=:picName '.
                                                        'where fk_user_id=:sessionId '.
                                                        'limit 1'   );  
                $this->pQuery->execute(array(   ':picName' => $this->picName, 
                                                ':sessionId' => $session -> sessionId()     ));
                if($this->pQuery->errorCode() == 0) {
                    $functions -> generateJsonMsg('success', null, null, null, $message->message['iconSuccess']);
                }   
                else     {
                    throw new Exception();
                }                               
            }
            catch(Exception $e) {
                $tException = new tException();
                $tException -> newException($e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
            }   
        }
    
asked by anonymous 07.08.2016 / 18:55

2 answers

1

Since it is Windows try to put the absolute path, for example:

C: / folder / where / you / will / save /

In addition, make sure this folder has full permission (0777)

The error that returned to you "failed to open stream: No such file or directory" says that the directory could not be opened, that is, it does not exist.     

07.08.2016 / 18:59
0

Apparently the error is not in the code snippet you passed, where is your function called? You are giving an error is in the User class; A class that does not exist in the repository is probably being instantiated.

    
07.08.2016 / 19:24