我的文件上传时出现此问题.我尝试上传我的PDF文件,同时检查验证是否TMP_NAME为空,当我检查$_FILES['document_attach']['error']值为1时,这意味着有一个错误.
但是当我尝试上传其他PDF文件时,它已成功上传.为什么其他PDF文件没有?
HTML
<form action="actions/upload_internal_audit.php" method="post" enctype="multipart/form-data">
<label>Title</label>
<span><input type="text" name="title" class="form-control" placeholder="Document Title"></span>
<label>File</label>
<span><input type="file" name="document_attach"></span><br>
<span><input type="submit" name="submit" value="Upload" class="btn btn-primary"></span>
</form>
Run Code Online (Sandbox Code Playgroud)
PHP
if(isset($_POST['submit'])){
$title = $_POST['title'];
$filename = $_FILES['document_attach']['name'];
$target_dir = "../eqms_files/";
$maxSize = 5000000;
if(!empty($title)){
if(is_uploaded_file($_FILES['document_attach']['tmp_name'])){
if ($_FILES['document_attach']['size'] > $maxSize) {
echo "File must be: ' . $maxSize . '";
} else {
$result = move_uploaded_file($_FILES['document_attach']['tmp_name'], $target_dir . $filename);
mysqli_query($con, "INSERT into internal_audit (id, title, file) VALUES ('', '".$title."', '".$filename."')");
echo …Run Code Online (Sandbox Code Playgroud) 此代码需要刷新或单击页面才能进入索引页面,然后在会话过期后更新数据库.
如何在会话过期后自动更新数据库,以便用户激活为0而不刷新或点击页面?
$idletime = 3600; //after 1hr the user gets logged out
if (time() - $_SESSION['timestamp'] >= $idletime){
$online = "UPDATE users SET active = 0 WHERE username = '".$_SESSION['username']."'";
mysqli_query($con, $online);
session_destroy();
header("Location:index.php");
} else {
$_SESSION['timestamp'] = time();
}
Run Code Online (Sandbox Code Playgroud) 我有这个代码。有人可以帮助我如何删除文件上传时的 fakepath 吗?谢谢你
html代码
<div id="file">Chose file</div>
<input type="file" name="file" style="display:none;"/>
Run Code Online (Sandbox Code Playgroud)
查询代码
var wrapper = $('<div/>').css({height:0,width:0,'overflow':'hidden'});
var fileInput = $(':file').wrap(wrapper);
fileInput.change(function(){
$this = $(this);
$('#file').text($this.val());
})
$('#file').click(function(){
fileInput.click();
}).show();
Run Code Online (Sandbox Code Playgroud)