Professional Documents
Culture Documents
حفظ الصور
حفظ الصور
حفظ الصور
showtopic=793
.
.
: :
PHP Function
is_uploaded_file
$_FILES
include
file_get_contents
addslashes
MySQL PHP
mysql_connect
mysql_error
mysql_select_db
mysql_query
mysql_fetch_row
SQL
phpmyadmin :
1 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
SQL
SQL
: :
MySQL :
: BLOB A -
CREATE DATABASE : SQL B -
CREATE TABLE : SQL C -
:
SQL - 1 phpmyadmin
phpmyadmin 2 -
PHP :
:
- 1 PHP :
- 2 PHP :
- 3 PHP :
- 4 PHP :
- 5 :
:
PHP MySQL
.
, 4.3.0 PHP
5
3.21 MySQL
PHP_Designer_2008_Professional
1 1
2 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
D.Mourad
MySQL :
.
BLOB : [A] -
Binary BLOB
Large Object
BLOB : MYSQL
BLOB
TINYBLOB
MEDIUMBLOB
LONGBLOB
database_name : .
up_image_db
3 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
(
column_name1 data_type option,
column_name2 data_type option,
.......
)
. table_name :
. column_name1 :
. data_type :
option : .
images :
6 :
AUTO_INCREMENT NOT NULL INT img_id
mysql_query . - 1 PHP
. - 2 phpmyadmin
D.Mourad
4 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
:
x 545) - ) %85 835
5 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
up_image_db
x 546) - ) %84 837
: 1 0.0038
: 2
0 up_image_db , : 3
6 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
0 up_image_db , : 3
images
: 4 :
x 546) - ) %84 837
7 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
SQL images
: 1
: 2
8 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
: 2
: 0 1
images : 4
phpmyadmin
phpmyadmin : [2] -
: http://localhost/phpmyadmin/index.php
:
x 546) - ) %84 837
:
x 546) - ) %84 837
9 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
: 1
phpmyadmin SQL : 2
up_image_db .
Image :
:
10 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
- 1 images
2 - 6
- 3
:
.
x 545) - ) %85 835
.
:
x 546) - ) %84 837
11 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
: 1
phpmyadmin SQL : 2
: 3 6 .
up_image_db images : 4
PHP
D.Mourad
PHP :
PHP
UP_IMAGES PHP
PHP :
:
HTML :
><html
><head
></title ><title
></head
><body
></h3 ><h3
>"<form enctype="multipart/form-data" action="#" method="post
><input type="hidden" name="MAX_FILE_SIZE" value="250000" /
><input type="file" name="fic" size=50 /
>" /"=<input type="submit" value
></form
12 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
></form
></body
></html
UP_IMAGES . index.php
250000 MAX_FILE_SIZE .
HTTP POST
PHP .
:
x 545) - ) %84 837
PHP ,
:
: PHP
[A] -
[B] -
[C] -
[D] -
[E] -
13 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
- [1] PHP :
<?php
;$ret = false
;)]'$ret = is_uploaded_file ($_FILES['fic']['tmp_name
) if ( !$ret
{
;" " echo
;return false
}
else
{
...
...
...
}
>?
:
$_FILES :
HTTP POST :
]'$_FILES['userfile']['name
]'$_FILES['userfile']['size
]'$_FILES['userfile']['type
]'$_FILES['userfile']['tmp_name
HTML : userfile :
fic HTML
name :
octets size :
type :
tmp_name :
is_uploaded_file :
FLASE . HTTP POST TRUE
) bool is_uploaded_file ( string filename
filename :
14 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
filename :
: 10 PHP
: - [2] PHP
<?php
;$taille_max = 250000
;]'$img_taille = $_FILES['fic']['size
) if ( $img_taille > $taille_max
{
;"! " echo
}
>?
$taille_max :
) ( $img_taille :
- [3] PHP :
;'' = $img_blob
;)]'$img_blob = file_get_contents ($_FILES['fic']['tmp_name
file_get_contents :
:
) file_get_contents ( string filename
filename
filename : .
- [4] PHP :
15 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
- [4] PHP :
connexion.php
:
<?php
;'$hote = 'localhost
;'$base = 'up_image_db
;'$user = 'root
;'' = $pass
;))( $cnx = mysql_connect ($hote, $user, $pass) or die (mysql_error
;))( $ret = mysql_select_db ($base) or die (mysql_error
>?
:
x 600) - ) %84 837
connexion.php : 1
MySQL : 2
up_image_db : 3
MySQL : 4
16 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
: 5 MySQL
mysql_connect :
TRUE MySQL
:
mysql_connect (string server , string username , string password )
string server :
string username : MySQL
string password : MySQL
mysql_error :
mysql_select_db :
string database_name :
: - [5]
17 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
INSERT INTO :
:
table_name :
column1 :
column1 value1 :
addslashes :
PHP "\" " '
mysql_query :
MySQL SQL
) mysql_query ( string query
A B C E :
<?php
)( function transfert
{
;$ret = false
;'' = $img_blob
;$img_taille = 0
;'' = $img_type
;'' = $img_nom
;$taille_max = 250000
;)]'$ret = is_uploaded_file ($_FILES['fic']['tmp_name
) if ( !$ret
{
;" " echo
;return false
}
else
{
;]'$img_taille = $_FILES['fic']['size
) if ( $img_taille > $taille_max
{
;"! " echo
;return false
}
18 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
}
$img_type = $_FILES['fic']['type'];
$img_nom = $_FILES['fic']['name'];
:
837 )%84 x 800) -
19 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
: 1 transfert.php
include :
PHP
:
include( string filename )
string filename : .
index.php :
<html>
<head>
<title>< /title>
</head>
<body>
<?php
include ("transfert.php");
if ( isset($_FILES['fic']) )
{
transfert();
}
?>
<h3>< /h3>
<form enctype="multipart/form-data" action="#" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="250000" />
<input type="file" name="fic" size=50 />
<input type="submit" value=" "/>
</form>
</body>
</html>
:
837 )%84 x 545) -
20 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
D.Mourad
PHP liste.php
:
<html>
<head><title>< /title></head>
<body>
<?php
include ("connexion.php");
$req = "SELECT img_nom, img_id FROM images ORDER BY img_nom";
$ret = mysql_query ($req) or die (mysql_error ());
837 )%84 x 545) -
21 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
mysql_fetch_row : 11
array mysql_fetch_row ( resource result )
13 apercu.php
php apercu.php
:
<?php
if ( isset($_GET['id']) )
{
$id = intval ($_GET['id']);
include ("connexion.php");
$req = "SELECT img_id, img_type, img_blob FROM images WHERE img_id = ".$id;
$ret = mysql_query ($req) or die (mysql_error ());
22 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
index.php
<html>
<head>
<title>< /title>
</head>
<body>
<?php
include ("transfert.php");
if ( isset($_FILES['fic']) )
{
transfert();
}
?>
<h3>< /h3>
<form enctype="multipart/form-data" action="#" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="250000" />
<input type="file" name="fic" size=50 />
<input type="submit" value=" "/>
</form>
<p><a href="liste.php">< /a></p>
</body>
</html>
:
837 )%84 x 545) -
23 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com
PHP - http://ib.vbsq.net/index.php?showtopic=793
24 24 11-01-2011 13:28
PDF created with pdfFactory Pro trial version www.pdffactory.com