PHP 画像アップロード コード_PHP チュートリアル

WBOY
リリース: 2016-07-20 11:09:03
オリジナル
1494 人が閲覧しました

PHP 画像アップロード コード/*この外国の PHP 画像アップロード コードは、優れたファイルおよび画像アップロード コードであり、オンライン ファイル管理もサポートしています。比較的優れた画像管理システムです。

phpチュートリアル画像アップロードコード
/*
この外国のphp画像アップロードコードは優れたファイルと画像アップロードコードであり、オンラインファイル管理もサポートしています。比較的優れた画像管理システムです。
*/

define('max', 2);

mysqltutorial_connect('localhost', 'mysqlユーザー名', 'mysqlパスワード');
mysql_select_db('your mysqlデータベース');

スイッチ($_post['action']) {
case 'upload':

$file = $_files['file']['tmp_name'];
$filename = $_files['file']['name '] ;

if($file) {

$max = max * 1024 * 1024;
$q = mysql_query("select * from `uploads` order by `batch` desc limit 1");
$r = mysql_fetch_assoc( $q);
$batch = $r['batch'];

if($filename == 'upload.zip') {

$zip = zip_open($file);

if ($zip) {

while ($zip_entry = zip_read($zip)) {

$size = zip_entry_filesize($zip_entry);
$name = ($zip_entry);

$type = substr( strrchr($name, '.'), 1);

if (zip_entry_open($zip, $zip_entry, "r")) {

$content = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
zip_entry_close ($zip_entry);

}

if ($size > $max) {

header('location: ./?error=4');
exit;

}

$error = true;

if ($type == 'gif' && $error) {

$error = false;



if ($type == 'png' && $error) {

$error = false;

}

if ($type == 'jpg' && $error) {

$error = false;

}
if ($type == 'jp例: && $error) {

$error = false;

}

if ($error) {

header('location: ./?error=2');

} else {

$id = 1;
$batch2 = $batch + 1;

while (file_exists("uploads/$id/$name")) {

$id++;

}
@mkdir("uploads/$id");

$fp = @fopen("アップロード/$id/ $name", "w");

if (@fwrite($fp, $content)) {

$q = mysql_query("`uploads` (`file`, `batch`) の値 ('uploads /$id/$name', '$batch2')");
$id = mysql_insert_id();

} else {

header('location: ./?error=3');

        }

fclose($fp);

}

}

header('location: ./?batch=' . $batch2);

zip_close($zip);

}

} else {

if (filesize($file) > $max) {

header('location: ./?error=4');
exit;

}

$error = true;

if (@imagecreatefromjpeg( $file) && $error) {

$error = false;

}

if (@imagecreatefromgif($file) && $error) {

$error = false;
}

if (@imagecreatefrompng($ file) && $error) {

$error = false;

}

if ($error) {

header('location: ./?error=2');

} else {

$id = 1;
$batch = $batch + 1;

while (file_exists("uploads/$id/$filename") {

$id++;

}
@mkdir("アップロード/$id");

if (@move_uploaded_file($file, "uploads/$id/$filename")) {

$q = mysql_query("`uploads` (`file`, `batch`) の値 ('uploads/$) に挿入id/$filename', '$batch')");
$id = mysql_insert_id();
header('location: ./?image=' . $id);

} else {

header('location: ./?error=3');

}


}

} else {

header('location: ./?error =1');

}

exit;

break;
}

header('content-type: text/html; charset=iso-8859-1');
ob_start('rewrite');
関数書き換え ($buffer) {
$host = $_server['http_host'];
$path = dirname($_server['php_self']);
$absolute = "http://$host$path/";
return preg_replace('#(href|src|action)="/#', "1="$absolute", $buffer);
}

?>



jpegr - 写真をすぐに共有
  
  
  
  
  
 
 
  

jpegr


  
  

// recently uploaded query
//$q = mysql_query('select * from `uploads` order by `id` desc limit 15');

$q = mysql_query('select count(`id`) as `count` from `uploads`');
$r = mysql_fetch_assoc($q);

?>
  


   

images hosted


   

if ($_get['p'] == 'help') {

?>
   

help


   

    

         

  •       how do i upload an image?

          just use the quick upload form on the top, or goto the home page to upload an image.
         

  •      

  •       what does "you must select a file to upload!" mean?

          this means that you clicked upload without selecting an image file.
         

  •      

  •       what does "that is a not a valid jpeg, gif, or png image." mean?

          this means that you uploaded a file, but it was not a jpeg, gif, or png image.
         

  •      

  •       what does "there was a problem with the server, and we were unable to upload your image." mean?

          this means your file was accepted, but it did not get saved, you will need to try again, or upload another image.
         

  •      

  •       what does "the file you selected was too big, mb is the maximum." mean?

          this means that you tried to upload a file that was too big.
         

  •     

   

} elseif ($_get['p'] == 'terms-of-service') {

?>
   

terms of service


   

    when you upload to jpegr you agree to the following;
    

         
  • you will not use jpegr to upload pornographic content, any violation of this agreement may result in ban, and immediate removal of content.

  •      
  • you will not abuse jpegr's upload form.

  •      
  • any violation may result in permanent ban.

  •     

   

} else {

if (is_numeric($_get['image'])) {

$q = mysql_query("select * from `uploads` where `id` = '$_get[image]'");
$r = mysql_fetch_assoc($q);
$root_ = 'http://' . $_server['http_host'] . dirname($_server['php_self']) . '/';

?>
   

here is your image


   

    click here to view your image


    

    

    

    " onfocus="this.select();" />

    

    visit jpegr"); ?>" onfocus="this.select();" />

    

    " onfocus="this.select();" />

    if you want to upload another image, you can go back or use the form below!


   

}

if (is_numeric($_get['batch'])) {

$q = mysql_query("select * from `uploads` where `batch` = '$_get[batch]'");

?>
   

viewing batch #


   

    to view an image in full size, just click it.


   

while($r = mysql_fetch_assoc($q)) {

?>
    image #<?php echo $r['id']; ?>

}

?>
   


   
   


    

beta image slideshow


    
    

   

   
   
   
   

   
   

share this batch with your friends


   

   
    

    

    if you want to upload another batch, you can go back or use the form below!


   

}

?>
   

upload an image or photo


   

    

  switch ($_get['error']) {
   case 1:
    $error = 'you must select a file to upload!
';
   break;
   case 2:
    $error = 'that is a not a valid jpeg, gif, or png image.
';
   break;
   case 3:
    $error = 'there was a problem with the server, and we were unable to upload your image.
';
   break;
   case 4:
    $error = 'the file you selected was too big, ' . max . 'mb is the maximum.
';
   break;
  }
  
?>
    
    you can upload a jpeg, gif, or png image. (max mb)


    
    you can also upload a zip named upload.zip, containing multiple images.


    
    

    

    
   


}

?>
  


  
  


??????
mysql_connect('localhost', 'mysql ユーザー名', 'mysql パスワード');
mysql_select_db('mysql データベース');
if ($_get['delete ']) {
$sql = "select * from `uploads` where `id` = '$_get[delete]'";
$q = mysql_query($sql);
$r = mysql_fetch_assoc($q);
unlink($_server['document_root'] . '/' . $r['file']);
$sql = "`id` = '$_get[delete]' の `uploads` から削除します";
$q = mysql_query($sql);
header('location: ' . $_server['http_referer']);
exit;
}
?>




jpegr 管理

& lt;/ head>

$sql = 'select ceil(count(`id`) / 20) as `count` from `uploads`';
$q = mysql_query($sql);
$r = mysql_fetch_assoc($q);
$pages = $r['count'];
$offset = ($_get['page'] > 0 && $_get['page'] <= $pages) ? ($_get['page'] - 1) * 20 : 0;
for ($i = 1; $i <= $pages; $i++) {
$class = ($_get['page'] == $i || $i == 1 && !$_get['ページ']) ? ' class="current"' : ' class="page"';
?>
>
}
?>







$sql = "select * from `uploads` order by `id` desc limit $offset,20";
$q = mysql_query($sql);
while ( $r = mysql_fetch_assoc($q)) {
?>



    
   
}
?>
  
id ファイル名 アクション
view, delete


css??
html, body {
 font-family: sans-serif;
 font-size: 12px;
 width: 800px;
 margin: 40px auto;
}
a {
 color: #105cb6;
 text-decoration: none;
}
h1 {
 margin: 0px 0px 10px 0px;
}
h1 a {
 -moz-outline-width: 0px;
}
h1 a img {
 border: 0px;
}
h3 {
 margin: 4px;
}
a:hover {
 text-decoration: underline;
}
#menu {
 background-color: #e5f5ff;
 padding: 8px;
 border: 1px solid #0099ff;
 position: relative;
}
#menu a {
 font-weight: bold;
 margin: 0px 8px 0px 0px;
}
#menu a:hover {
 text-decoration: underline;
}
#menu .right {
 margin: 0px;
 padding: 0px;
 position: absolute;
 top: 4px;
 right: 4px;
}
#menu .input {
 background-color: #ffffff;
 padding: 2px;
 border: 1px solid #0066ff;
}
#menu .button {
 font-family: sans-serif;
 padding: 2px;
 cursor: pointer;
}
#menu label {
 cursor: pointer;
}
#ads {
 background-color: #fde5f3;
 margin: 8px 0px;
 border: 1px solid #ec008c;
}
#recent {
 background-color: #e6fec9;
 margin: 8px 0px;
 padding: 2px;
 border: 1px solid #9dca68;
}
#main {
 background-color: #fffee5;
 padding: 8px;
 border: 1px solid #fff200;
}
#main h2 {
 font-size: 16px;
 color: #222222;
 margin: 0px;
}
#main form {
 margin: 4px 8px;
}
#main label {
 cursor: pointer;
}
#main .button {
 font-family: sans-serif;
 margin: 2px 0px 0px 0px;
 padding: 2px;
 cursor: pointer;
}
#main .right {
 font-size: 14px;
 float: right;
 padding: 0px 0px 2px 0px;
 border-bottom: 1px solid #444444;
}
#main div {
 margin: 4px 8px;
}
#main div label {
 font-weight: bold;
}
#main div input {
 font-family: sans-serif;
 font-size: 12px;
 width: 680px;
 padding: 2px;
 margin: 2px 0px 4px 4px;
}
#main div li {
 margin-bottom: 8px;
}
#links {
 background-color: #e9e8e8;
 margin: 8px 0px 0px 0px;
 padding: 4px 0px;
 border: 1px solid #231f20;
}
.spacer {
 height: 4px;
 overflow: hidden;
}

#slider {
 color: #ffffff;
 background-color: #232323;
 height: 400px;
 margin: 10px;
 padding: 5px;
 border: 1px solid #121212;
}

#slider h3 {
 color: #ffffff;
 font-size: 14px;
 line-height: 20px;
 background-color: #343434;
 height: 20px;
 margin: -5px -5px 15px -5px;
 padding: 5px;
}

#slider #slide #image {
 max-height: 350px;
}

源码下载地址

http://down.php100.com/php/2010/0927/20956.html


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444844.htmlTechArticlephp图片上传代码/*这款国外的php图片上传代码是一款好的文件与图片上传代码,并且还支持文件在线管理哦,是一款比较的好图片管理系统哦...
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のおすすめ
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート