PhP:无法移动上传文件



我不能使我的move_uploaded_file()不工作,没有错误显示:/

这是我的表格:

<form enctype="multipart/form-data" name="addNewCarnet" action="carnet.php" method="post">
                            <div><br>
                                <label for="carnetTitle">Titre de la page :</label><input type="text" name="carnetTitle" value="" /><br>
                                <br>
                                <label for="pageText">Texte :</label><br><br>
                                <textarea class="ckeditor" type="textarea" name="pageText"></textarea><br>
                                <br>
                                <div class="input-file-container">
                                    <input class="input-file" name="newPagePic" type="file">
                                    <label for="newPage" class="input-file-trigger labelImage" tabindex="0">Image</label>
                                </div>
                                <p class="file-return"></p>
                                <br>
                                <br>
                                <input type="submit" name="submitNewPage" value="Envoyer"><br>
                            </div>
                        </form>

和PhP:

if ($_FILES['newPagePic']['error'] > 0) $erreur = "Erreur lors du transfert"; // Vérifier l'upload
            else echo "transfert réussi";
            var_dump($_FILES);
            $extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png' ); // Vérification extension
            $extension_upload = strtolower(  substr(  strrchr($_FILES['newPagePic']['name'], '.')  ,1)  );
            if(!(in_array($extension_upload,$extensions_valides))) echo 'Extension incorrecte !';
            //Créer un dossier 'images/users/"id_user"'
            $destination_path = getcwd().DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'users'.DIRECTORY_SEPARATOR.$_SESSION["user_id"].DIRECTORY_SEPARATOR;
            if (!(is_dir($destination_path))) mkdir($destination_path, 0777, true);
            $nom = $_FILES['newPagePic']['name'];
            if(is_writable($destination_path))
            {
                echo "ok<br>";
            }
            else
            {
                echo "no writable<br>";
            }
            if(move_uploaded_file($_FILES['newPagePic']['tmp_name'], $destination_path.$nom))
              echo 'Transfert réussi';
            else
              echo $_FILES['newPagePic']['error'] ."<br>". $_FILES['newPagePic']['tmp_name'] ."<br>". $destination_path.$nom;

下面是回显:

https://i.stack.imgur.com/OlLQl.png

我不知道怎么了…我已经厌倦了这个上传的东西:(

谢谢你的帮助

尝试替换

if(move_uploaded_file($_FILES['newPagePic']['tmp_name'], $destination_path.$nom))

if(move_uploaded_file($_FILES['newPagePic']['tmp_name'], $destination_path.basename($_FILES['newPagePic']['name']));

相关内容

  • 没有找到相关文章

最新更新