Hejsa.
Jeg køre jo min egen webserver vil jeg lige sige som det første...
På den webserver, der ligger en masse php jeg har lavet, og jeg har så modificeret et upload script jeg fandt på nettet - Men, det virker sgu inte, og jeg forstår ikke en brik af hvad der er galt...
<?php
#lav et nyt kodeord! koden skal være 8 tegn lang og tilfældig. :p
$start="QWERTYUIOPASDFGHJKLZXCVBNMmnbvcxzlkjhgfdsapoiuytrewq1234567890";
$kode="";
srand((double)microtime()*1000000);
# echo "len=" . strlen($start);
for($i=0;$i<8;$i++) {
$kode=$kode . substr($start,(rand(1,strlen($start)-1)),1);
}
//?heck that we have a file
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 250Kb
$filename = basename($_FILES['uploaded_file']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpeg" || $ext == "JPEG" || $ext == "jpg" || $ext == "JPG") && ($_FILES["uploaded_file"]["size"] < 250000)) {
// && ($_FILES["uploaded_file"]["type"] == "image/jpeg")
//Determine the path to which we want to save this file
$newname = "../content/uploaded/". $kode ."_". $filename;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname)) {
//Attempt to move the uploaded file to it's new place
if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname)) {
print 'It\'s done! The file has been saved as: '.$newname;
} else {
echo "Error: A problem occurred during file upload!";
}
} else {
echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";
}
} else {
echo "Error: Only .jpeg images under 250Kb are accepted for upload";
}
} else {
echo "Error: No file uploaded";
}
?>
Fejlen er:
Warning: move_uploaded_file(../content/uploaded/OxoJizYN_hej1234.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/content/image.php on line 30
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phppeYUK4' to '../content/uploaded/OxoJizYN_hej1234.jpg' in /var/www/content/image.php on line 30
Error: A problem occurred during file upload!