Hej. Jeg er HELT ny inden for hjemmeside stuff, og har nok det dummeste spørgsmål, men anyways:
Skal have oprettet en upload funktion på min hjemmeside. Min hjemmeside er pt helt tom. Jeg prøvede at følge denne guide
http://www.w3schools.com[...]
Og jeg får oprettet de to filer, altså hhv. Upload-file html filen og upload file php filen. MEN så skriver den følgende:
(se nedenfor - men mit spørgsmål er, HVOR skal jeg skrive det ind? skal jeg oprette en ny fil?)
Saving the Uploaded File
The examples above create a temporary copy of the uploaded files in the PHP temp folder on the server.
The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location:
0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "";
echo "Type: " . $_FILES["file"]["type"] . "";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp-
_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
The script above checks if the file already exists, if it does not, it copies the file to the specified folder.
Note: This example saves the file to a new folder called "upload"
--
- Dan
-"everyone must be held accountable for their actions"