我正在嘗試爲私有云存儲系統創建安全的多文件上傳腳本。我不知道我做了什麼是好的,因爲我在3周前開始學習php。意想不到的'if'(T_IF),期待','或';'
我一直收到第59行的錯誤:if(move_uploaded_file($_FILES['file']['tmp_name'], $upload_dir));
我不知道我哪裏出錯了。如果有人能幫助我,那會很棒。
這是我的HTML
<form enctype="multipart/form-data" action="PHP/Click_Upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000000" />
Send this file: <input id="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
這是我的PHP
<?php
// Folder for upload files
$upload_dir = "../../SeagateHDD/Uploads";
//allowed file extensions
$allowed_types = array(
/* images extensions */
'jpeg', 'bmp', 'png', 'gif', 'tiff', 'jpg',
/* audio extensions */
'mp3', 'wav', 'aac', 'wma', 'm4a',
/* movie extensions */
'mov', 'flv', 'mpeg', 'mpg', 'mp4', 'avi', 'wmv',
/* document extensions */
'txt', 'pdf', 'ppt', 'pps', 'xls', 'doc', 'xlsx', 'pptx', 'ppsx', 'docx'
);
//Mime types not accectped
$mime_type_black_list= array(
/* Audio Mime Types */
'audio/basic', 'audio/L24', 'audio/ogg', 'audio/opus', 'audio/vorbis',
'audio/vnd.rn-realaudio', 'audio/vnd.wave', 'audio/webm', 'audio/example',
/* Images Mime Type */
'image/vnd.djvu', 'image/example',
/* Message Mime Type*/
'message/http', 'message/imdn+xml', 'message/partial', 'message/rfc822',
'message/example',
/* 3D Model Mime Type*/
'model/iges', 'model/mesh', 'model/vrml', 'model/x3d+binary',
'model/x3d+fastinfoset', 'model/x3d-vrml','model/x3d+xml', 'model/example'
);
//checks
if(isset($_FILES['submit'])){
//loop thought all the files
foreach ($_FILES ['submit']['tmp_name'] as $key => $tmp_name) {
$file_name = $_FILES['files']['name'][$key];
$file_size = $_FILES['files']['size'][$key];
$file_type = $_FILES['files']['type'][$key];
$file_tmp = $_FILES['files']['tmp_name'][$key];
//check files are not bigger than 100MB
if ($file_size > 100000000){
echo('File size must be less than 100MB');
}
// convert file name to lowercase and explode the file and look at the extension
$file_ext=strtolower(end(explode('.', $_FILES['file']['name'][$key])));
//check to see if file extension is accpeted
if(in_array($file_ext, $allowed_types)=== false);
echo('File extension not accepted');
//check files with mime types
if(in_array($file_ext, $mime_type_black_list)=== true);
echo('File mime type not accepted')
//move files from temp to choosen directory
if(move_uploaded_file($_FILES['file']['tmp_name'], $upload_dir));
{
echo ("File Uploaded");
}
else {
echo "Sorry, there was a problem uploading your file.";
}
}
}
<?php
'echo('File mime type not accepted')後面缺少分號:) – 2015-02-09 12:41:49
請發佈您收到的錯誤消息:-) – 2015-02-09 12:47:04