我无法使我的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;
这里有回音:
http://i.stack.imgur.com/OlLQl.png
我没有弄错...我已经厌倦了这个上传的东西:(
感谢您的帮助:)
答案 0 :(得分:0)
尝试替换
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']));