PHPjQuery:在何处指定uploadify目标文件夹
我有一个脚本运行,基本设置。当我将图像的目标文件夹硬编码到PHPjQuery:在何处指定uploadify目标文件夹,php,jquery,uploadify,Php,Jquery,Uploadify,我有一个脚本运行,基本设置。当我将图像的目标文件夹硬编码到uploadify.php,效果很好-现在我想使该文件夹成为动态的。我该怎么做 我有一个PHP变量$uploadify\u path,其中包含我想要的文件夹的路径。我已经在uploadify.php和check_exists.php中为$targetPath=$uploadify_path关闭了硬编码的$targetPath=path/to/directory,但它不起作用。文件上传动画运行,表示已完成,但目录仍然为空。文件也没有隐藏在其
uploadify.php
,效果很好-现在我想使该文件夹成为动态的。我该怎么做
我有一个PHP变量$uploadify\u path
,其中包含我想要的文件夹的路径。我已经在uploadify.php和check_exists.php中为$targetPath=$uploadify_path
关闭了硬编码的$targetPath=path/to/directory
,但它不起作用。文件上传动画运行,表示已完成,但目录仍然为空。文件也没有隐藏在其他地方
我看到Javascript中有一个指定文件夹的选项。我也试过了,但没用
如果有人能教我如何将这个可变目的地传递给uploadify,我将非常感激
我包括我当前的代码以进行检查(基本上是默认的):
Javascript文件
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'uploadify/uploadify.php',
// Put your options here
});
});
</script>
JS
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'formData' : {'path':'/file/path'},
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'uploadify/uploadify.php'
// Put your options here
});
});
</script>
JS
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'formData' : {'path':'/file/path'},
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'uploadify/uploadify.php'
// Put your options here
});
});
</script>
我的猜测是,您没有在任何随机文件夹上设置正确的权限,当您硬编码它时,它会起作用,因为您在该特定文件夹上设置了正确的权限。实际上,我在页面的前面创建了文件夹。全部设置为755。我确实手动将其更改为777只是为了测试,但没有乐趣…我的猜测是,您没有在任何随机文件夹上设置正确的权限,当您硬编码它时,它会起作用,因为您在该特定文件夹上设置了正确的权限。实际上,我在页面的前面创建了这些文件夹。全部设置为755。我确实手动将它们更改为777只是为了测试,但没有乐趣。。。
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_POST['path']; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetFile = $targetPath . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // 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.';
}
}