/ Forside / Teknologi / Udvikling / PHP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
PHP
#NavnPoint
rfh 3959
natmaden 3372
poul_from 3310
funbreak 2700
stone47 2230
Jin2k 1960
Angband 1743
Bjerner 1249
refi 1185
10  Interkril.. 1146
Upload simpel fil
Fra : Christian Helbo


Dato : 08-11-05 17:15

Hej

Jeg er ved at lære at bruge php. Jeg skal uploade en fil men får denne
besked i explorer:

--------------------
File Upload Results
path:
name: HDTV.txt
type: text/plain
size: 422

Warning: move_uploaded_file(/path/to/upload/directory/HDTV.txt)
[function.move-uploaded-file]: failed to open stream: No such file or
directory in C:\Programmer\Apache
Group\Apache2\htdocs\php\listing9.14.php on line 23

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
move 'C:\WINDOWS\TEMP\phpC.tmp' to
'/path/to/upload/directory/HDTV.txt' in C:\Programmer\Apache
Group\Apache2\htdocs\php\listing9.14.php on line 23
Couldn't copy
-------------------

I line 23 står der:
print "path: ".$file_array['tmp_name']."<br>\n";

resten ser således ud:

--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
   <title>Listing 9.14 A file upload script</title>
</head>

<body>

<h1>File Upload Results<h1>
<?php
$file_dir = "/path/to/upload/directory";

foreach($_FILES as $file_name => $file_array)
{
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "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");
print "file was moved!<br><br>";
}
}
?>

</body>
</html>

-------------------

Hvad er problemet? Jeg kan ikke lige finde fejlen.

Mvh.
Christian





 
 
Peter Brodersen (08-11-2005)
Kommentar
Fra : Peter Brodersen


Dato : 08-11-05 18:44

On 08 Nov 2005 16:14:58 GMT, Christian Helbo
<christian_helbo@hotmail.com> wrote:

>Jeg er ved at lære at bruge php. Jeg skal uploade en fil men får denne
>besked i explorer:

[..]

>Warning: move_uploaded_file(/path/to/upload/directory/HDTV.txt)
>[function.move-uploaded-file]: failed to open stream: No such file or
>directory in C:\Programmer\Apache
>Group\Apache2\htdocs\php\listing9.14.php on line 23

Fejlbeskeden siger, at mappen /path/to/upload/directory/ ikke findes.

><?php
>$file_dir = "/path/to/upload/directory";

Her angiver du selv den sti. Du bør rette den til hvor du rent faktisk
vil have filen hen.

--
- Peter Brodersen

Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408926
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste