javascript - Uploadify - 将目标文件夹更改为不同硬盘上的另一个文件夹
问题描述
我是新手上传。我最近c:/
在 uploadify 所在的本地安装了一个 xamp。我在 xampp 的 httdocs 中有一个 uploads 文件夹,我所有的上传文件都放在那里。但是,我想将我的上传移动到不同驱动器上的文件夹。我试图编辑uploadifive.php
但无济于事。我想'/uploads'(C:\xampp\htdocs\uploadify)
从(L:\ibi\apps\ibisamp\uploads)
. 我正在使用 html-5 版本。
这是我的代码:
索引.php
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Elavon MDM</title>
<link rel="icon" type="image/ico" href="favicon.ico">
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.uploadifive.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="uploadifive.css">
<style type="text/css">
body {
font: 13px Arial, Helvetica, Sans-serif;
}
.uploadifive-button {
float: left;
margin-right: 10px;
}
#queue {
border: 1px solid #E5E5E5;
height: 177px;
overflow: auto;
margin-bottom: 10px;
padding: 0 3px 3px;
width: 300px;
}
</style>
</head>
<body>
<!-- <h1>Data Management Upload Demo</h1> -->
<form>
<div id="queue"></div>
<input id="file_upload" name="file_upload" type="file" multiple="false">
<a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
</form>
<script type="text/javascript">
<?php $timestamp = time();?>
$(function() {
$('#file_upload').uploadifive({
'auto' : false,
'checkScript' : 'check-exists.php',
// 'fileTypeExts' : '*.csv',
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
'queueID' : 'queue',
'uploadScript' : 'uploadifive.php',
'onUploadComplete' : function(file, data) { console.log(data); }
});
});
</script>
</body>
</html>
上传.php
<?php
/*
UploadiFive
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
*/
// Set the upload directory
$uploadDir = '/uploads/';
// Set the allowed file extensions
$fileTypes = array('jpg', 'jpeg', 'gif', 'csv', 'png'); // Allowed file extensions
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
$targetFile = $uploadDir . $_FILES['Filedata']['name'];
// Validate the filetype
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array(strtolower($fileParts['extension']), $fileTypes)) {
// Save the file
move_uploaded_file($tempFile, $targetFile);
echo 1;
} else {
// The file type wasn't allowed
echo 'Invalid file type.';
}
}
?>
checkexists.php
<?php
/*
UploadiFive
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
*/
// Define a destination
$targetFolder = '/uploads'; // Relative to the root and should match the upload folder in the uploader script
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $targetFolder . '/' . $_POST['filename'])) {
echo 1;
} else {
echo 0;
}
?>
解决方案
尝试更换
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
和
$uploadDir = "L:\ibi\apps\ibisamp\" . $uploadDir;
推荐阅读
- matlab - 防止在 MATLAB 中使用 for 循环
- php - CSS(/ Wordpress)空白属性行为异常
- lua - Lua 中是否有 Add Assignment (+=) 或类似的?
- java - 异步或后台调用的最佳方式在活动中保持活跃
- aws-appsync - AWS AppSync Lambda 解析器获取查询返回类型
- php - 使用 woocommerce 创建产品时向客户或用户发送电子邮件
- r - 带因子变量的回归
- c - 我做的,while循环没有按我的意思工作:((C语言)
- vb.net - 如何在 vb.net 中打印 listview 表?
- git - “go get”无法下载 go 包,托管在 Github Entreprise 上的 git 存储库(在 VPN 之后)