文件上传 - 没有链接

时间:2015-07-20 15:16:44

标签: php file-upload

是否有人愿意帮我处理文件上传代码?

使用此代码添加文件时,该表只能获取文件名的概述而无需查看链接

我们缺少什么?

谢谢

add.php

<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_POST["submit"])) {
$result = mysql_query("INSERT INTO user(ime, prezime, email, adresa, grad, file) VALUES('".$_POST["ime"]."','".$_POST["prezime"]."','".$_POST["email"]."','".$_POST["adresa"]."','".$_POST["grad"]."','".$_POST["file"]."')");
if(!$result){
$message="Problem in Adding to database. Please Retry.";
} else {
header("Location:index.php");
}
}
?>
<link href="style.css" type="text/css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script>
function validate() {
var valid = true;
$(".demoInputBox").css('background-color','');
$(".info").html('');

if(!$("#ime").val()) {
$("#ime-info").html("(required)");
$("#ime").css('background-color','#FFFFDF');
valid = false;
}
if(!$("#prezime").val()) {
$("#prezime-info").html("(required)");
$("#prezime").css('background-color','#FFFFDF');
valid = false;
}
if(!$("#email").val()) {
$("#email-info").html("(required)");
$("#email").css('background-color','#FFFFDF');
valid = false;
}
if(!$("#adresa").val()) {
$("#adresa-info").html("(required)");
$("#adresa").css('background-color','#FFFFDF');
valid = false;
}
if(!$("#grad").val()) {
$("#grad-info").html("(required)");
$("#grad").css('background-color','#FFFFDF');
valid = false;
}
if(!$("#file").val()) {
$("#file-info").html("(required)");
$("#file").css('background-color','#FFFFDF');
valid = false;
}
return valid;
}
</script>
<form name="frmToy" method="post" action="" id="frmToy" onClick="return validate();">
<div id="mail-status"></div>
<div>
<label style="padding-top:20px;">Ime</label>
<span id="ime-info" class="info"></span><br/>
<input type="text" name="ime" id="ime" class="demoInputBox">
</div>
<div>
<label>Prezime</label>
<span id="prezime-info" class="info"></span><br/>
<input type="text" name="prezime" id="prezime" class="demoInputBox">
</div>
<div>
<label>E-mail</label>
<span id="email-info" class="info"></span><br/>
<input type="text" name="email" id="email" class="demoInputBox">
</div>
<div>
<label>Adresa</label>
<span id="adresa-info" class="info"></span><br/>
<input type="text" name="adresa" id="adresa" class="demoInputBox">
</div>
<div>
<label>Grad</label>
<span id="grad-info" class="info"></span><br/>
<input type="text" name="grad" id="grad" class="demoInputBox">
</div>
<div>
<label>File (pdf, doc, docx, xcl, xclx, jpg, png, gif)</label>
<span id="file-info" class="info"></span><br/>
<input type="file" name="file" id="file" class="demoInputBox">
</div>
<div>
<input type="submit" name="submit" id="btnAddAction" value="Add" />
</div>



index.php

<?php
foreach($result as $k=>$v) {
if(is_numeric($k)) {
?>
<tr>
<td><?php echo $result[$k]["datum_prijave"]; ?></td>
<td><?php echo $result[$k]["ime"]; ?></td>
<td><?php echo $result[$k]["prezime"]; ?></td>
<td><?php echo $result[$k]["email"]; ?></td>
<td><?php echo $result[$k]["adresa"]; ?></td>
<td><?php echo $result[$k]["grad"]; ?></td>
<td><?php echo $result[$k]["file"]; ?></td>

</tr>
<?php
}
}
if(isset($result["perpage"])) {
?>
<tr>
<td colspan="6" align=right> <?php echo $result["perpage"]; ?></td>
</tr>
<?php } ?>

0 个答案:

没有答案