我目前正在尝试在本地主机上为 .csv 文件上传表单,但是我还不能用它上传文件。这是因为我需要 chmod 本地主机上的目录。目前我正在使用这个:
$allowed_filetypes = array('.csv');
$max_filesize = 524288;
$upload_path = '/csvfiles/';
$filename = $_FILES['userfile']['name'];
// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path)){
$chmod = chmod ($upload_path & "/" & $_FILES, 777);
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)){
echo 'Upload succesful';
}else{
echo 'There was an error during the file upload. Please try again. :('; // It failed :(.
}
} else
die ('You cannot upload to the specified directory, please CHMOD the directory.');
我不确定这行代码需要是什么:
$chmod = chmod ($upload_path & "/" & $_FILES, 777);
我的脚本不断死亡,目录没有任何反应。
另外,如果您有此类事情的经验,请随时调试!:D
Side note: My OS is RHEL5
提前致谢,
-最大限度