tomovic
Anmeldungsdatum: 25. August 2013
Beiträge: 231
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<h1>PHP File Upload</h1>
<form methode="post" enctype="multipart/form-data" action="upload.php">
<label for="image">Image file</label>
<input type="file" id="image" name="image">
<button>upload</button>
</form>
</body>
</html>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | <?php
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
exit("POST request methode required");
}
if (empty($_FILES)) {
exit('$_FILES is empty');
}
print_r($_FILES);
?>
|
Ich bekomme immer –→ POST request methode required ...egal ob ich eine Datei ausgewählt habe oder nicht ?!
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 231
|
Ahhhhhhhhhhhhhhhhhhhhh Nach Studenlangen Suchen ....
| <form method'''e'''="post" enctype="multipart/form-data" action="upload.php">
|
☺ Code läuft
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 231
|
... Nachtrag, ein anderes Problem ist noch aufgetreten. Es kommt immer →>>> cant move updates file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 | <?php
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
exit("POST request methode required");
}
if (empty($_FILES)) {
exit('$_FILES is empty');
}
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime_type = $finfo->file($_FILES["image"]["tmp_name"]);
//exit($mime_type);
$filename = $_FILES["image"]["name"];
$destination = __DIR__ . "/var/www/html/ru/fan/Modelprofil/" . $filename;
if( ! move_uploaded_file($_FILES["image"]["tmp_name"], $destination)) {
exit("cant move updates file");
}
print_r($_FILES);
?>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
<title></title>
</head>
<body>
<h1>PHP File Upload</h1>
<form method="POST" enctype="multipart/form-data" action="uploadx.php">
<label for="image">Image file</label>
<input type="file" id="image" name="image">
<button>upload</button>
</form>
</body>
</html>
|
Wegen Schreibrechte ...
zum testen habe ich was von php.net ausprobiert, wenn die Datei existiert, dann wird auf dem Ubuntu Server gespeichert ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 |
<?php
$filename = 'test.txt';
$somecontent = "Füge dies der Datei hinzu\n";
// Sichergehen, dass die Datei existiert und beschreibbar ist.
if (is_writable($filename)) {
// Wir öffnen $filename im Anfüge-Modus.
// Der Dateizeiger befindet sich am Ende der Datei, und daher
// wird später $somecontent mit fwrite() dorthin geschrieben.
if (!$fp = fopen($filename, "a")) {
print "Kann die Datei $filename nicht öffnen";
exit;
}
// Schreibe $somecontent in die geöffnete Datei.
if (fwrite($fp, $somecontent) === FALSE) {
print "Kann nicht in die Datei $filename schreiben";
exit;
}
print "Fertig, in die Datei $filename wurde $somecontent geschrieben";
fclose($fp);
} else {
print "Die Datei $filename ist nicht schreibbar";
}
?>
|
|