我正在尝试建立一个用户可以上传文件的网站。我在此代码上方有一些基本参数(例如确保他们已登录等)。我已经缩小了我的错误所在。每当我尝试上传文件时,它都会加载很长时间(即使它只是一个小的 JPG),并且什么也不显示。我已经浏览了一堆以前的问题,但它们并没有真正帮助。
HTML
<form name="contact" action="action.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" multiple><br><div id="adder"></div>
<input type="submit" name="submit" value="Submit">
</form>
PHP
for($i=0; $i<count($_FILES['file']['name']); $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['file']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "uploads/".$_FILES['file']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)){
set_time_limit(0);
echo "Thanks for your submission! Your file was uploaded.;
}