位于webroot中的文件上传插件会忽略对目标文件夹的动态更改 [英] File Upload Plugin located in webroot ignores dynamic changes to the destination folder
问题描述
我有什么:
$ b
如果你建议一个很好的multiupload插件(简短的描述),我会将你的问题标记为一个答案,它很容易与cake php集成,并且可以自定义,所以数据库中的每个对象可以有自己的文件夹。
请考虑你的答案,任何解决这个问题都会有很多帮助。
您是否尝试使用表单数据发送会话名称,例如这里?
What I have:
I am using uploadify to upload files for the intranet application that Im writing.
I need to upload files to the directory that belongs to one user (with dynamic creation of directories).
My obviously incorrect solution :)
After any user logs in I create him a folder(title is user_id).
Now uploadify.php looks like this:
session_name("test_tool_cookie");
session_start();
$targetFolder = '/test_tool/app/webroot/uploadify/' . $_SESSION['Auth']['User']['user_id']; //Relative to the root
//the 3 lines above are my only change to the script
//$targetFolder = '/test_tool/app/webroot/uploadify/tmpFile'; //this was here before my changes
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('html' , 'docx', 'pdf', 'xls', 'xlsx', 'txt'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
THE PROBLEM
The above script won't upload the file into the folder (checked and wont upload the file anywhere else either).
If I change the $targetFile to a static value, it works fine.
- The Session value is correct (but ignored)
What else might earn an answered question
I will mark your question as an answer if you suggest a good multiupload plugin (with a brief description) that is easy to integrate with cake php, and will be customizable, so every object in the database can have it's own folder.
Please think about your answer, any solution for this problem will help a lot.
Did you to try send the session name with your form data like on the example here?
这篇关于位于webroot中的文件上传插件会忽略对目标文件夹的动态更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!