|
|
|
| Title : |
img_upload - array img_upload(string 'form field name', string 'image name', string 'destination');
Returns an array with 2 elements.
Index 0 contains the string name of the image.
Index 1 contains the string path to the image. |
| Categories : |
Graphics, PHP |
 Jeremiah Davis |
| Date : |
Jul 03rd 1998 |
| Grade : |
4 of 5 (graded 1 times) |
| Viewed : |
5511 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Jeremiah Davis |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
/*---------------------------------/// img_upload()
///----------------------------------------------*/
function img_upload($form_field,$img_name,$destination_path)
{
if (ereg("\.gif$",$img_name) || ereg("\.jpe?g",$img_name)) /* check to
see if the uploaded file is a valid format */
{
$i = "0"; /* if it is a
valid format check and see if the file name is already used */
$d = dir($destination_path);
while($entry=$d->read())
{
if ($entry == $img_name)
{
$img_name_in_use = "TRUE"; /* if the file
name is used, then set $img_name_in_use to TRUE */
}
++$i;
}
$d->close();
if ($img_name_in_use == "TRUE") /* if the file
name is used, then do this stuff */
{
$new_img_name = date('hms').$img_name; /* give the
file a uniqe name */
$new_img_location = $destination_path.'/'.$new_img_name; /* set the
new location of the file (path/filename.extension) */
copy($form_field,$new_img_location); /* copy the
file from /tmp to new location */
chmod($new_img_location, 0666); /* change the
permisions of the image file */
$img_array = array("$new_img_name","$new_img_location"); /* create an
array to be passed out of the function */
}
else /* if the file
name is used, then do this stuff */
{
$new_img_name = $img_name; /* give the
file a uniqe name */
$new_img_location = $destination_path.'/'.$new_img_name; /* set the new
location of the file (path/filename.extension) */
copy($form_field,$new_img_location); /* copy the
file from /tmp to new location */
chmod($new_img_location, 0666); /* change the
permisions of the image file */
$img_array = array("$new_img_name","$new_img_location"); /* create an
array to be passed out of the function */
}
}
else /* if the file
was not a valid type, then echo this error message */
{
echo '<FONT SIZE=4>'
.'The file you uploaded was of an incorect type, please only upload
.GIF or .JPG files'
.'<BR CLEAR=ALL>'
.'</FONT>'
."Hit your browser's back button to continue"
.'<P>';
}
return($img_array);
}
/*---------------------------------/// img_upload()
///----------------------------------------------*/ |
|
| PHP Image Compression using GD library Categories : PHP, Compression, GD image library, Graphics | | | This is a script that list all image files on a given directory, and displays
the thumbnails nicely formated within an HTML table. It also make use of
JavScript to open pop up windows when the users want to see the full photo. Categories : Graphics, PHP, Complete Programs, Java Script | | | Create images on fly using GD-Image Lib Categories : PHP, Graphics | | | EasyPhpThumbnail Class - The EasyPhpThumbnail class allows you to generate thumbnails and handle image manipulation for GIF, JPG and PNG on-the-fly. Categories : PHP, PHP Classes, Object Oriented, Graphics, GD image library | | | Barcodes On The Fly With GD Categories : Ecommerce, Graphics, HTML and PHP, PHP | | | Line graphics generation library written in PHP + GD library (spanish comments) Categories : PHP, Graphics, GD image library | | | a simple pie-chart in php3 (with gd) Categories : PHP, Graphics, GD image library, Charts and Graphs | | | Simple image counter Categories : PHP, Graphics, Filesystem, Beginner Guides | | | This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs | | | This program implements hot link prevention in php. It is useful for webmasters who do not have access to the server at a level where they can control hot linking can still supply some type of hot link prevention for thier site by using php. Categories : PHP, Filesystem, Graphics, Content Management | | | Easy slideshow with php. Just place this one file into a subdirectory where jpg files reside. An instant slideshow is yours. MS explorer only. Categories : PHP, Filesystem, Graphics | | | CAPTCHA[Image verification] Categories : PHP, Security, GD image library, Graphics, Sessions | | | The simple counter with use MySql and gd. Categories : MySQL, HTTP, Graphics, PHP, Databases | | | A couple of functions that convert an IP address into its color code and not-color-code. Useful when viewing an apache log with a mysql result grouped by IP Categories : PHP, Graphics, Databases | | | How to display any array in several rows and columns of a table. Not just
in one column or in alternate rows. This example shows a nice color table
generated with PHP, but can be used with any array values(e.g. Database) Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics | |
| |
| |
|