如果有人知道这段代码的问题,请告诉我。
基本上,我想使用 jQuery 上传文件。
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(event) {
$('#form1').submit(function(event) {
event.preventDefault();
$.post('post.php',function(data){
$('#result').html(data);
});
});
});
</script>
</head>
<body>
<form id="form1">
<h3>Please input the XML:</h3>
<input id="file" type="file" name="file" /><br/>
<input id="submit" type="submit" value="Upload File"/>
</form>
<div id="result">call back result will appear here</div>
</body>
</html>
我的php文件名为'post.php'
<?php
echo $file['tmp_name'];
?>
上传的文件名没有返回。问题是我无法访问已上传的文件。
先感谢! Shiv