您好我发现这个脚本用于上传文件并且它可以工作,但问题是当我上传文件时它没有显示我希望它在哪里 如何显示(图片):http://prntscr.com/97sbzq 我想来这里:http://prntscr.com/97scbi
以下是整页html和php:
Bufferpools
The database heap
The locklist
The utility heap
The package cache
The catalog cache
The shared sort heap, if it is enabled
A 20% overflow area
答案 0 :(得分:1)
您正在PHP脚本中打印PHP结果,这是在HTML启动之前。这是更正后的版本:
<?php
// Simple PHP Upload Script: http://coursesweb.net/php-mysql/
$output = ''; // Make a variable for output
$uploadpath = 'uploads/'; // directory to store the uploaded files
$max_size = 5000; // maximum file size, in KiloBytes
$alwidth = 6000; // maximum allowed width, in pixels
$alheight = 6000; // maximum allowed height, in pixels
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); // allowed extensions
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) {
$uploadpath = $uploadpath . basename( $_FILES['fileup']['name']); // gets the file name
$sepext = explode('.', strtolower($_FILES['fileup']['name']));
$type = end($sepext); // gets extension
list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']); // gets image width and height
$err = ''; // to store the errors
// Checks if the file has allowed type, size, width and height (for images)
if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.';
if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight;
// If no errors, upload the image, else, output the errors
if($err == '') {
if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) {
$output .= 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:';
$output .= '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>';
$output .= '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB';
if(isset($width) && isset($height)) $output .= '<br/>Image Width x Height: '. $width. ' x '. $height;
$output .= '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>';
}
else $output .= '<b>Unable to upload the file.</b>';
}
else $output .= $err;
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<title>SendIT / Free image Upload</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--style sheets-->
<link rel="stylesheet" href="css/filoxenia.css">
<link rel="stylesheet" href="css/magnific-popup.css">
<link rel="stylesheet" href="css/custom.css">
<script src="js/vendor/custom.modernizr.js"></script>
<style>
.wrap{
width: 700px;
margin: 10px auto;
padding: 10px 15px;
background: white;
border: 2px solid #DBDBDB;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-align: center;
overflow: hidden;
}
#preview {
color: red;
}
#preview img{
margin-top: 30px;
max-width: 100%;
border: 0;
border-radius: 3px;
-webkit-box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, .27);
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, .27);
overflow: hidden;
}
input[type="submit"]{
background-color: red;
border: 0;
color: white;
font-weight: bold;
font-style: italic;
padding: 6px 15px 5px;
cursor: pointer;
}
</style>
</head>
<body>
<header class="contain-to-grid">
<div class="row">
<div class="large-12 column">
<nav id="menu" class="top-bar">
<ul class="title-area">
<li class="name">
<a href="index.html">
<img src="images/logo.png" alt="logo">
</a>
</li>
<li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li><a href="plans.html">Home</a>
</li>
<li><a href="features.html">PLANS & PRICING</a>
</li>
<li><a href="terms.html">Terms</a>
</li>
<li id="signup"><a href="login.php" class="button no-margin">Login</a>
</li>
</ul>
</section>
</nav>
</div>
</div>
</header>
<section id="main" role="main">
<div class="breadcrumb-container">
<div class="row">
<div class="large-12 column">
<nav class="breadcrumbs animated bounceInDown">
<a href="index.html">Home</a>
<a class="current" href="#">Upload</a>
</nav>
</div>
</div>
</div>
<section class="part">
<div class="wrap">
<p>Valid formats: jpeg, gif, png, Max upload: 4mb (Free Users)</p>
<!-- simple file uploading form -->
<form id="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<input type="file" accept="image/*" name="fileup" />
<input id="button" type="submit" value="Upload">
</form>
<p><?php echo $output;?></p>
</div><!--wrap-->
<div id="space"></div>
</section>
</section>
<style>
#space {
padding-top: 450px;
}
</style>
<a id="back-top" href="#"><i class="icon-caret-up"></i></a>
<footer>
<div class="row">
<p class="small-12 large-4 large-uncentered column copyright">
Copyright © 2015 SendIT All Rights Reserved.
</p>
<p class="small-12 large-8 column social">
<a href="mailto:info@filoxenia.com"><i class="icon-envelope"></i></a>
<a href="#"><i class="icon-rss"></i></a>
<a href="//www.facebook.com" target="_blank"><i class="icon-facebook"></i></a>
<a href="//www.twitter.com" target="_blank"><i class="icon-twitter"></i></a>
<a href="//www.google.com/plus" target="_blank"><i class="icon-google-plus"></i></a>
<a href="//www.linkedin.com" target="_blank"><i class="icon-linkedin"></i></a>
<a href="skype:echo123?call" target="_blank"><i class="icon-skype"></i></a>
</p>
</div>
</footer>
<!-- Javascript -->
<!-- jQuery Library-->
<script type="text/javascript" src="js/vendor/jquery.form.js"></script>
<script type="text/javascript" src="js/vendor/script.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="js/vendor/jquery.magnific-popup.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.topbar.js"></script>
<script src="js/foundation/foundation.section.js"></script>
<script src="js/filoxenia.js"></script>
<script src="js/custom.js"></script>
</body>
</html>