iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 16, 2008
Who Are Your Top Friends on Facebook?
About
 
May 15, 2008
Reader Question - Would you host your client's work on your website?
About
 
May 15, 2008
How to Create an Ajax Autocomplete Text Field: Part 6
WebReference.com
 
May 14, 2008
Poll: Are the browser safe colors still needed?
About
 
May 14, 2008
Google Doctype launched
About
 
May 14, 2008
Web Editor Reviews - 6 New Reviews
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP

Storage and re-use of images using PHP/GD - Part 1 

  Views:    26391
  Votes:    3
by Gijs van Tulder 4/30/04 Rating: 

Synopsis:

In this article, we will write some scripts that automates the uploading, storage, converting and resizing of our images.
Pages: firstback1 2 3 5 6 7 forwardlast
The Article

The img tag

The last thing our function has to do, is actually create the img tag and return that.

    // create and return the img-tag
    $img = '<img src="img.php?f('.$img_file.')'.$attribs.'" '.
           'width="'.$out_w.'" height="'.$out_h.'" '.
           'alt="'.$img_info["img_alt"].'" border="0">';

    return $img;
}


The search form

To search the images, we start with a simple form. We can search by title, description, alt-text and image size. Save the form as, for example, search.html. You can change the form to suit your needs, but basically it would look like this:

<form enctype="multipart/form-data" method="post" action="search.php">
<b>Search image</b><br>
Title: <input name="title" type="text"><br>
Description: <input name="descr" type="text"><br>
Alt-text: <input name="alt" type="text"><br>
Width: <select name="width_expr"> <option value="=">=</option>

 <option value=">">></option>

<option value="<"><</option> </select>

<input name="width" type="text"><br>
Height: <select name="height_expr"> <option value="=">= </option>

<option value=">"> ></option>

<option value="<"><</option> </select>

<input name="height" type="text"><br>
Bytes: <select name="bytes_expr"> <option value="=">=</option>

<option value=">">></option>

<option value="<"><</option> </select>

 <input name="bytes" type="text"><br>
Type: <select name="type"> <option value="">any</option>

 <option value="JPG">JPG</option>

<option value="PNG">PNG</option></select><br>
<input type="submit" value="Search">
</form>


The search script

The input from the search form is sent to search.php. We will write this script now. After doing a search, it should return the images with the appropriate data. The user should also be able to click on the images for a popup larger version.

The first step is the inclusion of the img tag-script. Normally, you would also have to connect to the database. We already did that in the included script, so that's not necessary here.

include("imgtag.php");

Pages: firstback1 2 3 5 6 7 forwardlast

Similar/related articles:


 
  Sponsors