FORM file uploaden Mislukt..
(gedeeltelijke)code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
if (!$_FILES){
$form = "
<form action=\"".$_SERVER["PHP_SELF"]."\" enctype=\"multipart/form-data\" method=\"POST\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"500000\" />
<p><strong>Laad text-bestand:</strong>
<input type=\"file\" name=\"fileupload\" /></p>
<p><input type=\"submit\" value=\"upload!\" /></p>
</form>";
}elseif ($_FILES) {
if (($_FILES["tmp_name"] == "") && ($_FILES["name"] == "") && ($_FILES["size"] == "") && ($_FILES["tmp_name"] == "type")) {
header("Location: clips.php");
exit;
}
$filename = $_FILES["fileupload"]["name"];
$txt = fopen($filename, "r") or die("kan $filename niet openen!");?>
if (!$_FILES){
$form = "
<form action=\"".$_SERVER["PHP_SELF"]."\" enctype=\"multipart/form-data\" method=\"POST\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"500000\" />
<p><strong>Laad text-bestand:</strong>
<input type=\"file\" name=\"fileupload\" /></p>
<p><input type=\"submit\" value=\"upload!\" /></p>
</form>";
}elseif ($_FILES) {
if (($_FILES["tmp_name"] == "") && ($_FILES["name"] == "") && ($_FILES["size"] == "") && ($_FILES["tmp_name"] == "type")) {
header("Location: clips.php");
exit;
}
$filename = $_FILES["fileupload"]["name"];
$txt = fopen($filename, "r") or die("kan $filename niet openen!");?>
Eerst maak ik het upload form aan waarna ik met de SUPERglobal $_FILES het te uploaden *.txt wil bewerken. Dus eerst fopen(). Maar als ik de file wil uploaden dan krijg ik de volgende foutmelding:
Warning: fopen(clips.txt) [function.fopen]: failed to open stream: No such file or directory in G:\xampp\htdocs\DDJ\clips.php on line 21
kan clips.txt niet openen!
Als ik de te uploaden file in de dir zet van mn php-file lukt lukt het uploaden wel..
Onderstaande code doet t uplaoden vd file:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<?php $file_dir = "G:\\xampp\\htdocs\\DDJ\\";
//$file_dir = "//DDJ";
foreach($_FILES as $file_name => $file_array) {
echo "path: ".$file_array["tmp_name"]."<br/>\n";
echo "name: ".$file_array["name"]."<br/>\n";
//echo "type: ".$file_array["type"]."<br/>\n";
//echo "size: ".$file_array["size"]."<br/>\n";
if (is_uploaded_file($file_array["tmp_name"])) {
move_uploaded_file($file_array["tmp_name"], "$file_dir/".$file_array["name"]) or die ("Couldn't copy");
//echo "file was moved!<br/>";
}
} ?>
//$file_dir = "//DDJ";
foreach($_FILES as $file_name => $file_array) {
echo "path: ".$file_array["tmp_name"]."<br/>\n";
echo "name: ".$file_array["name"]."<br/>\n";
//echo "type: ".$file_array["type"]."<br/>\n";
//echo "size: ".$file_array["size"]."<br/>\n";
if (is_uploaded_file($file_array["tmp_name"])) {
move_uploaded_file($file_array["tmp_name"], "$file_dir/".$file_array["name"]) or die ("Couldn't copy");
//echo "file was moved!<br/>";
}
} ?>
Hoe kan ik uit elke willekeurige dir. files uploaden zonder de foutmelding?
mvg Vincent
Gewijzigd op 01/01/1970 01:00:00 door NiVin
moest het zijn...:)