آپلود عکس ( خیلی مهم )

sodahost

Member
سلام دوستان من یه فرم دارم چند input داره که یکی از اونا برای دریافت فایل عکس است .
می خواستم دوستان کمک کنن بگن که چطوری میشه عکس رو آپلود کنم در یک فولدر و اسم فایل را در بانک اطلاعاتی ذخیره کنم !!
فقط میخوام سورس خیلی پیچیده نباشه !! و اینکه کار کنه :!: چون بعضی از دوستان از جای دیگه فایل رو اینجا میزان برای دانلود !! بدونه اینکه اصلا تست کرده باشند !
منتظر جواب شما هستم !
 

www.nero.ir

Member
F1 اسم input هستش
$name هم اسم فایل که می خوای سیو کنی تو دیتابیس
PHP:
 if(is_uploaded_file($_FILES['F1']['tmp_name']))
 {
 move_uploaded_file($_FILES['F1']['tmp_name'], "../uploadbook/".$_FILES['F1']['name']);
 $name=$_FILES['F1']['name'];
 }
 

jhoseini

Member
با اجازه www.nero.ir !
یکی هم من گزاشتم، که میرزه تو دیتابیس
PHP:
if($_FILES['userfile']['size']>0){
  if(substr($_FILES['userfile']['type'],0,6)=='image/'){
    $pic = fread(fopen($_FILES['userfile']['tmp_name'], 'rb'), filesize($_FILES['userfile']['tmp_name'])); 
    $pic = '0x'.bin2hex($pic); 
    mysql_query(" insert into table_name (`fieldForFile`) values (  $pic  ) "); // deghat shavad, $pic bedune quotes, va `pic` az noe BLOB tu databasestructure entekhab shavad
  } else {
    echo "invalid file type";
  }
}
 
آخرین ویرایش:

irdavidnet

Banned
یه خیلی راحت تر
:
PHP:
$readdir = "../../uploads";
$allow = "jpg,jpeg,gif,bmp,pdf,png,txt,doc,rtf,zip,tar.gz,tiff,css,mpeg,mp3,midi,js,txt";

if (isset($_POST['SUBMIT'])) {
////// check for allow file
if ($_FILES['file']['type']=="image/jpeg" OR $_FILES['file']['type']=="image/jpg" OR $_FILES['file']['type']=="image/jpe" OR $_FILES['file']['type']=="image/pjpeg" OR $_FILES['file']['type']=="image/pjpg" OR $_FILES['file']['type']=="image/x-jpeg" OR $_FILES['file']['type']=="image/x-jpg" OR
$_FILES['file']['type']=="image/gif" OR $_FILES['file']['type']=="image/x-gif" OR $_FILES['file']['type']=="image/png" OR $_FILES['file']['type']=="image/x-png" OR $_FILES['file']['type']=="image/tif" OR $_FILES['file']['type']=="image/tiff" Or $_FILES['file']['type']=="image/bmp" Or $_FILES['file']['type']=="image/x-bmp"
Or $_FILES['file']['type']=="text/css" OR  $_FILES['file']['type']=="video/mpeg" Or $_FILES['file']['type']=="video/x-mpeg" OR $_FILES['file']['type']=="audio/mpeg" Or $_FILES['file']['type']=="audio/x-mpeg" OR $_FILES['file']['type']=="audio/midi" OR $_FILES['file']['type']=="audio/mid" OR $_FILES['file']['type']=="text/plain" OR $_FILES['file']['type']=="application/zip" OR $_FILES['file']['type']=="application/x-zip" OR $_FILES['file']['type']=="application/x-zip-compressed" OR $_FILES['file']['type']=="application/pdf" OR $_FILES['file']['type']=="application/msword" OR $_FILES['file']['type']=="application/x-javascript" OR $_FILES['file']['type']=="application/x-tar"){
  
if (eregi(".php",$_FILES['file']['name']) OR eregi(".php3",$_FILES['file']['name']) OR eregi(".php4",$_FILES['file']['name']) OR eregi(".asp",$_FILES['file']['name'])
OR eregi(".html",$_FILES['file']['name']) OR eregi(".htm",$_FILES['file']['name']) OR eregi(".php5",$_FILES['file']['name']) OR eregi(".aspx",$_FILES['file']['name'])
){
echo "فرمت فايل غير قابل قبول است";
}else {
if (file_exists($readdir.'/'.$_FILES['file']['name'])){
echo "فايل مورد نظر در دايرکتوري وجود دارد";}
else {
if ($_FILES['file']['name']=='index.htm' OR $_FILES['file']['name']=='index.html' OR $_FILES['file']['name']=='defualt.html'  OR $_FILES['file']['name']=='defualt.html'  OR $_FILES['file']['name']=='defualt.asp'  OR $_FILES['file']['name']=='defualt.aspx'
OR $_FILES['file']['name']=='index.php' OR $_FILES['file']['name']=='index.php3' OR $_FILES['file']['name']=='index.php4' OR $_FILES['file']['name']=='index.php5' OR $_FILES['file']['name']=='index.txt'
){
echo "نام وارد شده معتبر نيست";}
else {
if ($_FILES['file'] != "") {
   $dir ="../../uploads/";
   if (copy($_FILES['file']['tmp_name'], $dir.$_FILES['file']['name'])){
   $query=mysql_query("INSERT INTO `upload` (name,size,type,dir) value ('$_FILES[file][name]','".filesize($_FILES['file']['tmp_name'])."','$_FILES[file][type]','$readdir'");
   if ($query){
   echo "فایل مورد نظر با موفقیت ارسال شد";
   }} else {
   exit("متاسفانه مشکلی در ارسال فایل مورد نظر وجود دارد".mysql_error());
   }
  }
}}}}else {echo "فرمت فايل غير قابل قبول مي باشد";}}
این دکمه تشکر رو بزنی حتماً
 

hidensoft

Member
باز هم تاکید می کنم از OOP استفاده کنید .

PHP:
<?php 
/*
Easy PHP Upload - version 2.29
A easy to use class for your (multiple) file uploads

Copyright (c) 2004 - 2006, Olaf Lederer
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of the finalwebsites.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

______________________________________________________________________
available at http://www.finalwebsites.com 
Comments & suggestions: http://www.finalwebsites.com/contact.php
*/
 
class file_upload {

    var $the_file;
	var $the_temp_file;
    var $upload_dir;
	var $replace;
	var $do_filename_check;
	var $max_length_filename = 100;
    var $extensions;
	var $ext_string;
	var $language;
	var $http_error;
	var $rename_file; // if this var is true the file copy get a new name
	var $file_copy; // the new name
	var $message = array();
	var $create_directory = true;
	
	function file_upload() {
		$this->language = "en"; // choice of en, nl, es
		$this->rename_file = false;
		$this->ext_string = "";
	}
	function show_error_string() {
		$msg_string = "";
		foreach ($this->message as $value) {
			$msg_string .= $value."<br>\n";
		}
		return $msg_string;
	}
	function set_file_name($new_name = "") { // this "conversion" is used for unique/new filenames 
		if ($this->rename_file) {
			if ($this->the_file == "") return;
			$name = ($new_name == "") ? strtotime("now") : $new_name;
			$name = $name.$this->get_extension($this->the_file);
		} else {
			$name = $this->the_file;
		}
		return $name;
	}
	function upload($to_name = "") {
		$new_name = $this->set_file_name($to_name);
		if ($this->check_file_name($new_name)) {
			if ($this->validateExtension()) {
				if (is_uploaded_file($this->the_temp_file)) {
					$this->file_copy = $new_name;
					if ($this->move_upload($this->the_temp_file, $this->file_copy)) {
						$this->message[] = $this->error_text($this->http_error);
						if ($this->rename_file) $this->message[] = $this->error_text(16);
						return true;
					}
				} else {
					$this->message[] = $this->error_text($this->http_error);
					return false;
				}
			} else {
				$this->show_extensions();
				$this->message[] = $this->error_text(11);
				return false;
			}
		} else {
			return false;
		}
	}
	function check_file_name($the_name) {
		if ($the_name != "") {
			if (strlen($the_name) > $this->max_length_filename) {
				$this->message[] = $this->error_text(13);
				return false;
			} else {
				if ($this->do_filename_check == "y") {
					if (preg_match("/^[a-z0-9_]*\.(.){1,5}$/i", $the_name)) {
						return true;
					} else {
						$this->message[] = $this->error_text(12);
						return false;
					}
				} else {
					return true;
				}
			}
		} else {
			$this->message[] = $this->error_text(10);
			return false;
		}
	}
	function get_extension($from_file) {
		$ext = strtolower(strrchr($from_file,"."));
		return $ext;
	}
	function validateExtension() {
		$extension = $this->get_extension($this->the_file);
		$ext_array = $this->extensions;
		if (in_array($extension, $ext_array)) { 
			// check mime type hier too against allowed/restricted mime types (boolean check mimetype)
			return true;
		} else {
			return false;
		}
	}
	// this method is only used for detailed error reporting
	function show_extensions() {
		$this->ext_string = implode(" ", $this->extensions);
	}
	function move_upload($tmp_file, $new_file) {
		umask(0);
		if ($this->existing_file($new_file)) {
			$newfile = $this->upload_dir.$new_file;
			if ($this->check_dir($this->upload_dir)) {
				if (move_uploaded_file($tmp_file, $newfile)) {
					if ($this->replace == "y") {
						//system("chmod 0777 $newfile"); // maybe you need to use the system command in some cases...
						chmod($newfile , 0777);
					} else {
						// system("chmod 0755 $newfile");
						chmod($newfile , 0755);
					}
					return true;
				} else {
					return false;
				}
			} else {
				$this->message[] = $this->error_text(14);
				return false;
			}
		} else {
			$this->message[] = $this->error_text(15);
			return false;
		}
	}
	function check_dir($directory) {
		if (!is_dir($directory)) {
			if ($this->create_directory) {
				umask(0);
				mkdir($directory, 0777);
				return true;
			} else {
				return false;
			}
		} else {
			return true;
		}
	}
	function existing_file($file_name) {
		if ($this->replace == "y") {
			return true;
		} else {
			if (file_exists($this->upload_dir.$file_name)) {
				return false;
			} else {
				return true;
			}
		}
	}
	function get_uploaded_file_info($name) {
		$str = "File name: ".basename($name)."\n";
		$str .= "File size: ".filesize($name)." bytes\n";
		if (function_exists("mime_content_type")) {
			$str .= "Mime type: ".mime_content_type($name)."\n";
		}
		if ($img_dim = getimagesize($name)) {
			$str .= "Image dimensions: x = ".$img_dim[0]."px, y = ".$img_dim[1]."px\n";
		}
		return $str;
	}
	// this method was first located inside the foto_upload extension
	function del_temp_file($file) {
		$delete = @unlink($file); 
		clearstatcache();
		if (@file_exists($file)) { 
			$filesys = eregi_replace("/","\\",$file); 
			$delete = @system("del $filesys");
			clearstatcache();
			if (@file_exists($file)) { 
				$delete = @chmod ($file, 0775); 
				$delete = @unlink($file); 
				$delete = @system("del $filesys");
			}
		}
	}
	// some error (HTTP)reporting, change the messages or remove options if you like.
	function error_text($err_num) {
		switch ($this->language) {
			case "nl":
			$error[0] = "Foto succesvol kopieert.";
			$error[1] = "Het bestand is te groot, controlleer de max. toegelaten bestandsgrootte.";
			$error[2] = "Het bestand is te groot, controlleer de max. toegelaten bestandsgrootte.";
			$error[3] = "Fout bij het uploaden, probeer het nog een keer.";
			$error[4] = "Fout bij het uploaden, probeer het nog een keer.";
			$error[10] = "Selecteer een bestand.";
			$error[11] = "Het zijn alleen bestanden van dit type toegestaan: <b>".$this->ext_string."</b>";
			$error[12] = "Sorry, de bestandsnaam bevat tekens die niet zijn toegestaan. Gebruik alleen nummer, letters en het underscore teken. <br>Een geldige naam eindigt met een punt en de extensie.";
			$error[13] = "De bestandsnaam is te lang, het maximum is: ".$this->max_length_filename." teken.";
			$error[14] = "Sorry, het opgegeven directory bestaat niet!";
			$error[15] = "Uploading <b>".$this->the_file."...Fout!</b> Sorry, er is al een bestand met deze naam aanwezig.";
			$error[16] = "Het gekopieerde bestand is hernoemd naar <b>".$this->file_copy."</b>.";
			break;
			case "de":
			$error[0] = "Die Datei: <b>".$this->the_file."</b> wurde hochgeladen!"; 
			$error[1] = "Die hochzuladende Datei ist gr&ouml;&szlig;er als der Wert in der Server-Konfiguration!"; 
			$error[2] = "Die hochzuladende Datei ist gr&ouml;&szlig;er als der Wert in der Klassen-Konfiguration!"; 
			$error[3] = "Die hochzuladende Datei wurde nur teilweise &uuml;bertragen"; 
			$error[4] = "Es wurde keine Datei hochgeladen"; 
			$error[10] = "W&auml;hlen Sie eine Datei aus!."; 
			$error[11] = "Es sind nur Dateien mit folgenden Endungen erlaubt: <b>".$this->ext_string."</b>";
			$error[12] = "Der Dateiname enth&auml;lt ung&uuml;ltige Zeichen. Benutzen Sie nur alphanumerische Zeichen f&uuml;r den Dateinamen mit Unterstrich. <br>Ein g&uuml;ltiger Dateiname endet mit einem Punkt, gefolgt von der Endung."; 
			$error[13] = "Der Dateiname &uuml;berschreitet die maximale Anzahl von ".$this->max_length_filename." Zeichen."; 
			$error[14] = "Das Upload-Verzeichnis existiert nicht!"; 
			$error[15] = "Upload <b>".$this->the_file."...Fehler!</b> Eine Datei mit gleichem Dateinamen existiert bereits.";
			$error[16] = "Die hochgeladene Datei ist umbenannt in <b>".$this->file_copy."</b>.";
			break;
			//
			// place here the translations (if you need) from the directory "add_translations"
			//
			default:
			// start http errors
			$error[0] = "File: <b>".$this->the_file."</b> successfully uploaded!";
			$error[1] = "The uploaded file exceeds the max. upload filesize directive in the server configuration.";
			$error[2] = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form.";
			$error[3] = "The uploaded file was only partially uploaded";
			$error[4] = "No file was uploaded";
			// end  http errors
			$error[10] = "Please select a file for upload.";
			$error[11] = "Only files with the following extensions are allowed: <b>".$this->ext_string."</b>";
			$error[12] = "Sorry, the filename contains invalid characters. Use only alphanumerical chars and separate parts of the name (if needed) with an underscore. <br>A valid filename ends with one dot followed by the extension.";
			$error[13] = "The filename exceeds the maximum length of ".$this->max_length_filename." characters.";
			$error[14] = "Sorry, the upload directory doesn't exist!";
			$error[15] = "Uploading <b>".$this->the_file."...Error!</b> Sorry, a file with this name already exitst.";
			$error[16] = "The uploaded file is renamed to <b>".$this->file_copy."</b>.";
			
		}
		return $error[$err_num];
	}
}
?>

اینم مثال :

PHP:
<?php
include ("upload_class.php"); //classes is the map where the class file is stored (one above the root)
echo getcwd();
$max_size = 1024*250; // the max. size for uploading
	
$my_upload = new file_upload;

$my_upload->upload_dir = getcwd()."/"; // "files" is the folder for the uploaded files (you have to create this folder)
$my_upload->extensions = array(".png", ".zip", ".pdf", ".jpg"); // specify the allowed extensions here
// $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!)
$my_upload->max_length_filename = 50; // change this value to fit your field length in your database (standard 100)
$my_upload->rename_file = true;
		
if(isset($_POST['Submit'])) {
	$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
	$my_upload->the_file = $_FILES['upload']['name'];
	$my_upload->http_error = $_FILES['upload']['error'];
	$my_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true
	$my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename
	$new_name = (isset($_POST['name'])) ? $_POST['name'] : "";
	if ($my_upload->upload($new_name)) 
	{ // new name is an additional filename information, use this to rename the uploaded file
		$full_path = $my_upload->upload_dir.$my_upload->file_copy;
		$info = $my_upload->get_uploaded_file_info($full_path);
		// ... or do something like insert the filename to the database
	}
}
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Upload example</title>
<style type="text/css">
<!--
label {
	float:left;
	display:block;
	width:120px;
}
input {
	float:left;
}
-->
</style>
</head>

<body>
<h3>File upload script:</h3>
<p>Max. filesize = <?php echo $max_size; ?> bytes.</p>
<form name="form1" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>"><br>
  <label for="upload">Select a file...</label><input type="file" name="upload" size="30"><br clear="all">
  <label for="name">New name?</label><input type="text" name="name" size="20"> 
  (without extension!) <br clear="all">
  <label for="replace">Replace ?</label><input type="checkbox" name="replace" value="y"><br clear="all">
  <label for="check">Validate filename ?</label><input name="check" type="checkbox" value="y" checked><br clear="all">
  <input style="margin-left:120px;" type="submit" name="Submit" value="Submit">
</form>
<br clear="all">
<p><?php echo $my_upload->show_error_string(); ?></p>
<?php if (isset($info)) echo "<blockquote>".nl2br($info)."</blockquote>"; ?> 
</body>
</html>

موفق باشید.
 

sodahost

Member
سلام مرسی از جواب
ببین من این کد رو دارم
میخوام وقتی کاربر فایل رو انتخاب کرد اطلاعات اینجوری ذخیره بشه !
اسم دیتابیس من = test
اسم جدول من = aks
حالا هر جور که خودت صلاح می دونی میخوایی فایل رو تو دیتابیس ذخیره کنه یا اینکه فایل رو توی یک فولدر ذخیره کنه و بعد آدرس اونو تو دیتابیس قرار بده !
فقط خواهشا کد هاش تا میتونه کم باشه !!
و اینکه یه کمی هم توضیح بده کد هاشو !!
 

پیوست ها

  • upload.txt
    508 بایت · بازدیدها: 3

imanmir

Member
کد کامل آپلود عکس در دیتابیس

با سلام
اینم کد مورد نظر
کد DB
create table mune1
(id int(10)primary key auto_increment,
title char(255) not null,
time char(255) not null,
memo text not null,
pic blob,
name char(255) not null,
mark char(100) not null);

کدinsert
<form action="regnews.php" method="post" enctype="multipart/form-data">
<table cellspacing="0" cellpadding="0" width="98%" height="100%">
<tr>
<td align="center">

<table border='0' width='85%' align='center'>
<tr>
<td align='center' bgcolor='#D5D5D5' width='21%' height='22'>
<input type='text' name='title' size='35' style='font-family: Tahoma; font-size: 8pt; color: #800000; text-align: center'></td>
<td width='10%' align='center' bgcolor='#D3DCE3' height='22'>
<span style='font-size: 8pt'>ÚäæÇä ÎÈÑ</span></td>
</tr>
<tr>
<td align='center' bgcolor='#D5D5D5' width='21%'>
<span lang='en-us'><font color='#800000'>$jdate</font></span></td>
<td width='10%' align='center' bgcolor='#D3DCE3'>
<span style='font-size: 8pt'>ÊÇÑیÎ ÎÈÑ</span></td>
</tr>
<tr>
<td align='center' bgcolor='#D5D5D5' width='21%'>
<script language='JavaScript' type='text/javascript' src='wysiwyg.js'>
</script>
<textarea id='textarea1' name='memo' style='height: 201; width: 361;' >

</textarea>
<script language='javascript1.2'>
generate_wysiwyg('textarea1');
</script>
</td>
<td width='10%' align='center' bgcolor='#D3DCE3'>
<span style='font-size: 8pt'>ãÊä ÎÈÑ</span></td>
</tr>
<tr>
<td align='center' bgcolor='#D5D5D5' width='21%'>
<input type='hidden' name='MAX_FILE_SIZE' value='2000000'>
<input type='file' name='pic' size='44' style='font-family: Tahoma; font-size: 8pt; color: #800000; text-align: center; border: 1px solid #800000' dir='ltr'></td>
<td width='10%' align='center' bgcolor='#D3DCE3'>
ÊÕæیÑ ãæÑÏ äÙÑ1<span lang='en-us'>33</span>*1<span lang='en-us'>76</span></td>
</tr>
<tr>
<td align='center' bgcolor='#D5D5D5' width='21%'>
<input type='submit' value='ËÈÊ ÇØáÇÚÇÊ' name='B1' style='font-family: Tahoma; font-size: 8pt; color: #000080; text-align: center'></td>
<td width='10%' align='center' bgcolor='#D3DCE3'>
<input type='reset' value='ÏæÈÇÑå äæیÓی' name='B2' style='font-family: Tahoma; font-size: 8pt; color: #000080; text-align: center'></td>
</tr>
</table>

<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
error_reporting(~E_ALL);
$B1=$_POST['B1'];
$name=LOGINMASSAGE;
$title=$_POST['title'];
$time=$jdate;
$memo=$_POST['memo'];
$pic=$_FILES['pic']['tmp_name'];
$picsize=$_FILES['pic']['size'];
$x='new';
if($B1=='ËÈÊ ÇØáÇÚÇÊ')
{
if($title=='')
{
echo "<font color='#FF0000'>áØÝÇ ÈÑÇی ÇÏÇãå ÚäæÇä ÎÈÑ ÑÇ ËÈÊ äãÇییÏ</font><p>";
}
else
if ($memo=='')
{
echo"<font color='#FF0000'>áØÝÇ ÈÑÇی ÇÏÇãå ˜ÇÑ ãÊä ÎÈÑ ÑÇ æÇÑÏ äãÇییÏ</font><p>";
}
else
{
if($picsize>'350000')
{
echo $pic."حجم فایل ارسال شده بالا می باشد 350</span>kb<span lang='fa'>
می باشد لطفا حجم را کاهش دهید";
}

if($pic=="")
{
$val="''";
}
else
{
if(is_uploaded_file($pic))
{
$fp=fopen($pic,'rb');
$val = fread($fp,filesize($pic));
$val = '0x' . bin2hex($val);
}
}
$sql = mysql_query("INSERT INTO mune6 (title,time,memo,name,pic,mark) VALUES ( '".$title."','".$time."','".$memo."','".$name."',".$val.",'".$x."') " ) ;
}
if($sql)
{
echo"<font color='#FF0000'>ÇÎÈÇÑ ãæÑÏ äÙÑ ÈÇ ãæÝÞیÊ ËÈÊ ÔÏ</font><p>";
}
else
{
echo"<font color='#FF0000'>ÚãáیÇÊ ËÈÊ Èå ÏÑÓÊی ÇäÌÇã äÔÏ</font><p>";
}
}

?>

کد نمایش :
echo "<img src='show.php?table=mune1 & id=$row3[0] & rowsdo=4' width='176' higth='133'>";
کد نمایش فایل show.php:
<?php
header('Content-Type: image/jpeg');
//db connect
$idrow=addslashes($_GET[id]);
$tablerow=$_GET
;
$markdo=$_GET[markdo];
$rowsdo=$_GET[rowsdo];
class showpic
{
function show($table,$id,$mark,$rows)
{
if($mark)
{
$q="select * from $table where mark='$mark' and id='$id' ";
}
else
{
$q="select * from $table where id='$id'";
}
$r=mysql_query($q);
$row=mysql_fetch_array($r);
echo $row[$rows];
}
}
$sql=new showpic();
$sql->show($tablerow,$idrow,$markdo,$rowsdo);
?>
فقط یک مشکل داره زمانی که نمایش می ده روی آن کلیک راست کنید و مسیر آن را ببنید مسیر دیتابیس رو هم نمایش می ده و این از نظر امنیتی خوب نیست
 

jhoseini

Member
imanmir جان دستت درد نکنه، زحمت کشیدی، اما این چه وضع کد گزاشتنه، فایل کنید، آپلود کنید اینجا که مردم دپرس نشن اینو میبینن! : )
 

sodahost

Member
سلام مرسی فقط اگه لطف کنی تو یه فایل Txt یا یه چیزی بنویسی که بفهمیم خوب میشه این اصلا معلوم نیست چی به چی هستش ولی به هر حال ممنون
 

sodahost

Member
سلام مرسی از جواب
1 - دوست عزیز من اینو تست کردم کار نکرد !
بانک اطلاعاتی + اسم جدول رو هم کامل ساختم !!
صفحه لود میشه ولی تو بانک ذخیره نمیکنه !
واسه این کد تنظیماتی رو نباید تو php.ini انجام بدم ؟
من برنامه WAMP2 رو روی لوکال نصب کردم منتظر جواب شما هستم
ایمیل من [email protected] منتظر ایمیل شما هستم !!
 

imanmir

Member
کد کامل آپلود عکس در دیتابیس

با سلام به دوستان عزیز
شرمنده دیر شده آخه مسافرت بودم
من یک فایل zip گذاشتم که تمامی کد داخلش هست
فقط گفتم یک مشکل داره اینکه در زمان نمایش تصویر وقتی که برید آدرسشو ببنید نام جدول هم نمایش می ده و امینتی مشکل داره
 

پیوست ها

  • uploadDbOk.zip
    4.2 کیلوبایت · بازدیدها: 11

جدیدترین ارسال ها

بالا