私のHTMLFORMコード:
<form action="upload.php" method="GET" enctyped="multipart/form-data">
<label for="file"> Filename:</label>
<input type="file" name="loadedFile" id="file"/></br>
<input type="submit" name="uploadItNow" value="Submit"/>
hai, this is this the uploader.
</form>
PHPファイルアップローダースクリプト:
if (isset($_GET['uploadItNow'])) // checks if submit button has pressed
{
if ($_FILES['loadedFile']["error"] > 0)
echo "Error: ". $_FILES["loadedFile"] ["error"]. "</br>";
else
{
echo "Upload: ". $_FILES["loadedFile"] ["name"]. "</br>";
echo "Type: ". $_FILES["loadedFile"] ["type"] . "</br>";
echo "Stored in: " .$_FILES["loadedFile"] ["tmp_name"];
echo "Size: ". ($_FILES["loadedFile"] ["size"] / 1024). " Kb</br>";
//Copies file from TEMP_PHP dir to d.default dir
if (file_exists("." . $_FILES["loadedFile"]["name"]))
{
echo $_FILES["loadedFile"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["loadedFile"]["tmp_name"],"." . $_FILES["loadedFile"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["loadedFile"]["name"];
}
}
}
何らかの理由でそれが機能しないので、私のスクリプトはこのコードに行き続けます:
echo $_FILES["loadedFile"]["name"] . " already exists. ";