zhaozhilu

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


<link href="css/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.v2.1.4.min.js"></script>


<script type="text/javascript">
$(document).ready(
function() {
$(
\'#file_upload\').uploadify({
\'uploader\' : \'js/uploadify.swf\',
\'script\' : \'upload.php\',
\'cancelImg\' : \'js/cancel.png\',
\'folder\' : \'uploads\',
\'auto\' : true
});
});
</script>

</head>
<body>
<input id="file_upload" name="file_upload" type="file" />
</body>
</html>

 

upload.php

<?php 
if (!empty($_FILES)) {
$tempFile = $_FILES[\'Filedata\'][\'tmp_name\'];

$targetPath = $_SERVER[\'DOCUMENT_ROOT\'] . $_REQUEST[\'folder\'] . \'/\';
$targetFile = str_replace(\'//\',\'/\',$targetPath) . $_FILES[\'Filedata\'][\'name\'];

if( move_uploaded_file($tempFile,$targetFile)){
echo true;
}else{
echo false;
}

}
?>



只要加载一下几个js(jquery-1.4.2.min.js , swfobject.js , jquery.uploadify.v2.1.4.min.js)就可以直接使用

官网地址http://www.uploadify.com/

分类:

技术点:

相关文章: