我是新手,本来是学习java的,但刚一进公司就搞php网页,一点都不懂啊,这两天经理让我做个上传压缩文件的按钮,可以上传,但在目标文件里却接收不到我上传的文件,我把代码复制过来,希望各路大侠能给指点下,感激不尽。
<html>
<link href="css/style.css?t=20130428" type="text/css" rel="stylesheet" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery.uploadify.js" type="text/javascript"></script>
<script src="js/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
<li id="tpfile" style="background:none; cursor:pointer;" >
<form >
<div id="queue"></div>
<input id="file_uploadtp" name="file_uploadtp" type="file" multiple="true">
</form>
<script type="text/javascript">
$(function() {
$('#file_uploadtp').uploadify({
'formData' : {
'uuid' : ''+uuid
},
'swf' : 'uploadify.swf',
'uploader' : 'uploadifytp.php',
'method' : 'get',
'successTimeout' : 10,
'fileSizeLimit' : '1GB',
'fileTypeExts': '*.zip;*.rar;*.doc',
'fileTypeDesc' : '请选择*.zip;*.rar;*.doc的文件',
'width':'50px',
'buttonText':'批量上传',
'onUploadComplete' : function(file) {
},'onUploadSuccess': function(event, response, status) {
if(response==1){
spsc="1";
alert("文件类型不符合要求");
}else {
alert("文件上传成功");
}
}
});
});
</script>
</li>
</html><?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
$targetFolder = '/nrgl/photos'; // Relative to the root
$uuid=$_GET['uuid'];//$verifyToken = md5('unique_salt' . $_POST['timestamp']);
//if (!empty($_FILES) && $_POST['token'] == $verifyToken) {$rand=rand(0,999999999);//if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile =rtrim($targetPath,'/') . '/'.$rand.'.' .substr($_FILES['Filedata']['name'],-3,3);
// Validate the file type
$fileTypes = array('zip','rar','doc'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo $targetFile;
} else {
echo '1';
}
<html>
<link href="css/style.css?t=20130428" type="text/css" rel="stylesheet" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery.uploadify.js" type="text/javascript"></script>
<script src="js/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
<li id="tpfile" style="background:none; cursor:pointer;" >
<form >
<div id="queue"></div>
<input id="file_uploadtp" name="file_uploadtp" type="file" multiple="true">
</form>
<script type="text/javascript">
$(function() {
$('#file_uploadtp').uploadify({
'formData' : {
'uuid' : ''+uuid
},
'swf' : 'uploadify.swf',
'uploader' : 'uploadifytp.php',
'method' : 'get',
'successTimeout' : 10,
'fileSizeLimit' : '1GB',
'fileTypeExts': '*.zip;*.rar;*.doc',
'fileTypeDesc' : '请选择*.zip;*.rar;*.doc的文件',
'width':'50px',
'buttonText':'批量上传',
'onUploadComplete' : function(file) {
},'onUploadSuccess': function(event, response, status) {
if(response==1){
spsc="1";
alert("文件类型不符合要求");
}else {
alert("文件上传成功");
}
}
});
});
</script>
</li>
</html><?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
$targetFolder = '/nrgl/photos'; // Relative to the root
$uuid=$_GET['uuid'];//$verifyToken = md5('unique_salt' . $_POST['timestamp']);
//if (!empty($_FILES) && $_POST['token'] == $verifyToken) {$rand=rand(0,999999999);//if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile =rtrim($targetPath,'/') . '/'.$rand.'.' .substr($_FILES['Filedata']['name'],-3,3);
// Validate the file type
$fileTypes = array('zip','rar','doc'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo $targetFile;
} else {
echo '1';
}
解决方案 »
- 几多行代码的领袖才能自称是架构师?
- 请问一下,我安装WAMPSERVER2.0以后,在局域网访问网页时提示:您无权查看该网页.
- 对discuz二次开发遇到的小问题。
- 快递查询,快递公司是否有接口之类的功能
- discuz 请教
- 分享框架式网站系统的权限处理,尤其针对大型项目和二次开发项目
- 我想在头部模板中,插入表单,做一个关联的二级菜单,从数据库取值,可找不到head.php文件,我该写了那???
- imagecolorallocate 分配失败
- php中画一个不规则图形,填充图片,并生成超链接。能不能实现。
- testlink执行用例报错Cannot use string offset as an array
- 网站后台验证合法
- 织梦文章添加问题
请确认该目录真实存在,并有写权限