我需要有关使用 php 上传多个文件的帮助。当我上传具有不同字符名称的文件时,它会更改文件名,例如,如果它"Kayıt.doc"
在上传后更改为"Kayıt.doc"
. 我不想发生这种情况,我该怎么办?请帮忙.... :)
这是html页面....
<!doctype html>
<html>
<body>
<form action="cvupload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="539" height="75" border="0">
<tr>
<td width="220"><div align="right">Step 2 : </div></td>
<td width="309">Please upload your cv now </td>
</tr>
<tr>
<td><span class="style14">Submit your cv (ms word / zip format)</span></td>
<td><label for="file"></label>
<input type="file" name="file[]" id="file" /></td>
</tr>
<tr>
<td> </td>
<td><label for="Submit"></label>
<input type="submit" name="Submit" value="Submit" id="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
这是PHP页面...
<?php
$toplam = count($_FILES["file"]["name"]);
for ($i = 0; $i < $toplam; $i++)
{
foreach ($_FILES['file']['name'] as $filename)
{
if (((($_FILES["file"]["type"][$i] == "application/msword")||($_FILES["file"]["type"][$i] == "application/zip")))
&& ($_FILES["file"]["size"][$i] > 0))
{
if ($_FILES["file"]["error"][$i] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"][$i] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"][$i] . "<br />";
echo "Type: " . $_FILES["file"]["type"][$i] . "<br />";
echo "Size: " . ($_FILES["file"]["size"][$i] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"][$i] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"][$i]))
{
echo $_FILES["file"]["name"][$i] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"][$i],
"upload/" . $_FILES["file"]["name"][$i]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"][$i];
}
}
}
else
{
echo "Invalid file";
}
}
?>
当我<input type="file" name="file" id="file" />
只对 1 个文件使用这样的括号时,它可以,但对于多个文件,它不起作用。