Code: Alles auswählen
<html>
<head></head>
<body>
<h4> File uploads </h4>
<form enctype="multipart/form-data" action="/upload/upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="200000000" />
Send this file: <input name="uploadedfile" type="file" />
<input type="submit" value="Send File" />
</form>
max allowed upload: 200MByte
</body>
</html>
Code: Alles auswählen
<?php
$target_path = "/pub/incoming/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
echo "Source=" . $_FILES['uploadedfile']['name'] . "<br />";
echo "Destination=" . $destination_path . "<br />";
echo "Target path=" . $target_path . "<br />";
echo "Size=" . $_FILES['uploadedfile']['size'] . "<br />";
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
Versuche ich, z.B. eine jpg-Datei hochzuladen, bekomme ich im funktionierenden Fall folgende Ausgabe im Browser:
Code: Alles auswählen
Source=emu.jpg
Destination=
Target path=/pub/incoming/emu.jpg
Size=198142
The file emu.jpg has been uploaded
Code: Alles auswählen
Source=P5252475.JPG
Destination=
Target path=/pub/incoming/P5252475.JPG
Size=0
There was an error uploading the file, please try again!