2014-12-02 80 views
-1

我想上傳文件到我的網站,但由於一些奇怪的原因,它不工作。存在=真正觸發,所以這意味着它應該是正確的?它給了我$ error = true ;.下面是我的代碼:有問題與PHP文件上傳

HTML:

<input size="30" enctype="multipart/form-data" name="profile_icon" id="register-profile_icon" class="elgg-input-file" type="file"> 

PHP:

$profile_icon = $_FILES["profile_icon"]; 
if($profile_icon){ 
    $exists=true; 
} 
$error = false; 
if(empty($profile_icon["name"])){ 
    register_error(elgg_echo("profile_manager:register_pre_check:missing", array("profile_icon"))); 
    $error = true; 
} 
+3

'ENCTYPE = 「多部分/格式數據」''中屬於

'函數。 – 2014-12-02 04:54:09

回答

1

使用$_FILES["profile_icon"]["tmp_path"]文件路徑。

$_FILES["profile_icon"]這將包含如姓名,tmp_path,類型,大小等

在另外一個值的數組注意,您需要enctype屬性添加到您的<form>

並且存在可用於移動載功能move_uploaded_file();