PHP beginner |
|
Ik was bezig met een kleine file uploader te maken toen ik op een probleem stuitte:
Warning: move_uploaded_file(../dump/) [function.move-uploaded-file]: failed to open stream: Is a directory in /customers/woutr.be/woutr.be/httpd.www/upload/upload.php on line 4
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpqeudsr' to '../dump/' in /customers/woutr.be/woutr.be/httpd.www/upload/upload.php on line 4
Warning : move_uploaded_file(../dump /) [function.move -uploaded -file]: failed to open stream : Is a directory in /customers /woutr .be /woutr .be /httpd .www /upload /upload .php on line 4 Warning : move_uploaded_file() [function.move -uploaded -file]: Unable to move '/tmp/phpqeudsr' to '../dump/' in /customers /woutr .be /woutr .be /httpd .www /upload /upload .php on line 4
Dit is het scriptje dat ik gemaakt had:
<?php
if(isset($_POST['submit'])) {
if($_FILES['Filedata']['name'] && $_POST['randomPass'] == "test") {
move_uploaded_file($_FILES['Filedata']['tmp_name'], "../dump/" . $_POST['name']);
} else {
echo "Nothing to see here";
}
}
?>
<form method="post" action="#" enctype="multipart/form-data">
<input type="text" name="name" value="test" />
<input type="text" value="test" name="randomPass" />
<input type="file" id="Filedata" name="Filedata" />
<input type="submit" value="submit" name="submit" />
</form>
<?php if(isset($_POST['submit'])) { if($_FILES['Filedata']['name'] && $_POST['randomPass'] == "test") { } else { echo "Nothing to see here"; } } ?> <form method="post" action="#" enctype="multipart/form-data"> <input type="text" name="name" value="test" /> <input type="text" value="test" name="randomPass" /> <input type="file" id="Filedata" name="Filedata" /> <input type="submit" value="submit" name="submit" /> </form>
Nu vind ik het raar dat dit niet werkt, want ik heb in dezelfde map een ander bestand waarbij het wel werkt
Dat ander bestand ziet er zo uit:
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['upload'])) {
if(isset($_FILES['file'])) {
if(isset($_POST['random'])) {
$file = explode(".", $_FILES['file']['name']);
$ext = array_pop($file);
$name = sha1(md5(time() + rand(0, 99999999)));
$newName = $name.".".$ext;
} else {
$newName = $_FILES['file']['name'];
}
if(move_uploaded_file($_FILES['file']['tmp_name'], "../dump/" . $newName)) {
echo "<input type='text' value='http://dump.woutr.be/".$newName."' class='uploaded' />";
}
} else {
echo "Gelieve een bestand te selecteren";
}
}
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['upload'])) { if(isset($_FILES['file'])) { if(isset($_POST['random'])) { $file = explode(".", $_FILES['file']['name']); $newName = $name.".".$ext; } else { $newName = $_FILES['file']['name']; } echo "<input type='text' value='http://dump.woutr.be/".$newName."' class='uploaded' />"; } } else { echo "Gelieve een bestand te selecteren"; } }
Nu vraag ik mij af wat er verschillend is dat de eerste niet werkt
|