原因是我单独整了个子域名来托管文件提供下载之类的, 然后传文件要上FTP特别麻烦, 于是自己写了个简单的小程序. 实现的功能: 输入正确的用户名和密码后进入上传页面 无刷新上传 上传的文件保存到文件夹 包括三个文件: index.html check_usr.php upload_file.
原因是我单独整了个子域名来托管文件提供下载之类的, 然后传文件要上FTP特别麻烦, 于是自己写了个简单的小程序.
实现的功能:
包括三个文件:
Usr: Passwd:
<?php session_start(); $usr = $_POST['usr']; $passwd = $_POST['passwd']; $_SESSION['usr'] = "yourUsrName";//your name here $_SESSION['passwd'] = "yourPasswd";//your password here if ($passwd != $_SESSION['passwd'] && $usr != $_SESSION['usr']){echo "ERROR";} elseif ($passwd == $_SESSION['passwd'] && $usr == $_SESSION['usr']){ ?> <!--if usrname & passwd are correct--> Filename: <!--jq ajax upload, require jquery.form.js--> $(document).ready(function() { $('#editor-form').submit(function() { var options = {target: '#ooo',url: 'upload_file.php',type: 'post',success: function() {$('#filepath').val($('#ooo').text());}}; $(this).ajaxSubmit(options); return false; }); }); <?php }?>
<?php $dir = 'files/'; if (! file_exists ( $dir )) { mkdir ( $dir );//create a folder if not exists } if (( ($_FILES["file"]["type"] == "application/octet-stream")//.rar/.exe/.7z etc. || ($_FILES["file"]["type"] == "application/x-zip-compressed")//.zip || ($_FILES["file"]["type"] == "application/javascript"))//.js && ($_FILES["file"]["size"] < 200000) ) { if ($_FILES["file"]["error"] > 0) {echo "Return Code: " . $_FILES["file"]["error"] ; } else { if (file_exists("files/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file( $_FILES["file"]["tmp_name"], "files/" . $_FILES["file"]["name"] );// save file } } } else {echo "Invalid file";} ?>
php_upload_system is coded by http://xiaohudie.net. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl