GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Aug-2003, 02:30
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point

upload thumbnail


hi,

i got problem regarding uploading thumbnails from any location or if i just copy the image name in the below text field let say egg.gif it will upload the thumbnail is it possible or everytime i have to click on browse to get the complete location to get the thumbnail.
anybody please let me know how to upload thumbnails so that when i submit the form i can get thumbnails in same page as well as when i add 2nd,3rd iamges and so on it will add one another in same page like
3.egg.gif and so on in ascending order
2.flower.gif
1.bus.gif

<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="tree" value="<?=$tree ?>" />
<table border="0" cellpadding="0" cellspacing="5">
<tr>
<td>&nbsp;</td> -->
<td align="right"><input type="file" name="file" /></td>


<td colspan="5" align="center">
<br /><input class="biggray" type="submit" name="submit" value="TRANSFER" />
</td>
</tr>
</table><br />
</form>

thanks in advance
  #2  
Old 26-Aug-2003, 07:41
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
This tutorial will explain how to upload files:
www.phpbuilder.com

To maintain a numbering for each thumbnail, you'll have to store info about each image somehow. A text file or a database will do nicely, and you can then store a text comment about each thumbnail as you wish.

GF
  #3  
Old 26-Aug-2003, 07:49
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point
thanks garth for your sincere advice ,well i tried to do something like this i m having all images stored in folder let say ../asset/upload
so when im trying to upload then system process become so slow and its very time taking to get image
could you please let me know in which line the error is

PHP Code:

<?PHP

$folder = "../assets/upload/";
$handle = opendir($folder);

# Making an array containing the files in the current directory:
while ($file = readdir($handle))
{
    $files[] = $file;
}
closedir($handle);

#loop through the files, and only take files that are images.
foreach ($files as $file) {
    $f_name = $file;
    $fileextention = split ('[.]', $f_name);
    $fileext = $fileextention[count($fileextention)-1];
    if($fileext=="gif" or $fileext=="png" or $fileext=="bmp" or $fileext=="jpg" or $fileext=="jpeg" or $fileext=="jpe" or $fileext=="tif" or $fileext=="tiff") {
        $filename[] = $file;
    }
}
#echo out the images...
echo "<table style=\"width: 100%;\">\n\t
\t<tr>\n\t\t<td>Images</td>";

for ($i = 0; $i < count($filename); $i++) {
    if ($i % 3 == 0) {
        echo "\n\t</tr>\n\t<tr>\n";
    }
    echo "\t\t<td style=\"width: 33%; border: gray 1px solid; padding: 3px;\"><img src=\"".$folder.$filename[$i]."\" alt=\"Gallery Image\"\"></img><td>\n";
}
echo"\n\t</tr>
</table>\n";

?>






<table border="0" width="500" cellspacing="0" cellpadding="0">
    <form action="<?=$HTTP_SERVER_VARS['PHP_SELF'];?>"  method="post" enctype="multipart/form-data">
        <tr>
            <td width="130" height="20" align="left" valign="top"><font color="#000000" face="verdana" size="1">Image To Upload :</font><br></td>
            <td width="370" height="40" align="left" valign="top"><input type="file" size="40" name="file"></td>
        </tr>
        <tr>
            <td colspan="2" height="20" width="500" align="center" valign="top"><input type="submit" name="upload" value="Upload"></td>
        </tr>
    </form>
</table>


and how i can ge image size 170*111pixels is it possible

thanks in advance
  #4  
Old 26-Aug-2003, 10:08
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
I can't see offhand why the script is slowing down yor PC/server. File system functions do slow things down a little, but you shouldn't notice it that much.

How big are the images that are being uploaded. If you're uploading 5mb images over a 56k modem, it will be slow, and the server will slow down, waiting and waiting...

Try sticking in some timing code,to see what is taking time.www.desilva.biz

You can resize images to exact numbers using the GD library, but it's tough to learn. Have a look at this script off Hotscripts.com:
www.hotscripts.com.

GF
  #5  
Old 27-Aug-2003, 02:02
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point
thanks alot but i tried to upload image from (../assets/upload)which is 3.4kb size but still the system becoms too slow
and may be im using PHP version 4.0.6 which i dont have rights to update and GD librarries :------
GD Support enabled
GD Version 1.2

hope you have any clue for this
  #6  
Old 27-Aug-2003, 07:12
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point
sorry Pyro for late reply as im using older version of PHP 4.0.6
as i dont ahve any rights to update it moreover its on remote server and GD library:------- GD Support enabled and
GD Version 1.2

i can explain you once again whats the problem actually there is path in server ../assets/upload and here everyday all thumbnails is stored and clients have rights to upload all these thumbnails to his machine for that when he uplaod and submit the form he can see thumbnails and when i try below code it works for all functions like it checks whether file is more and file exits or not but never tells that it uploaded sucessfully,but i will be very glad if you modify htis code so that it can print all thumbnails in order from altest to older thumbnails

PHP Code:

<?php
                  $maxsize = "16384";
                  $maxwidth = "200";

          if(isset($HTTP_POST_VARS['upload'])){
           if (!empty($HTTP_POST_FILES['file']['name'])){
             $nama=$HTTP_POST_FILES['file']['tmp_name'];
             $allowed = array(".jpg"=>"2",".jpeg"=>"2");
             $size = getImageSize($nama);
             $imgtype = $size[2];
  if(!in_array($imgtype,$allowed)) {
     echo "<font face=\"verdana\" size=\"2\" color=\"#000000\"><b>Sorry! File Format Not Allowed!</b></font><br>";
                exit();
                         }
        $files = $HTTP_POST_FILES['file']['size'];
                    if($files > $maxsize){
                  echo "<font face=\"verdana\" size=\"1\" color=\"#000000\">Exceeded maximum file size</font><br>\n";
                echo "<font face=\"verdana\" size=\"1\" color=\"#000000\">Maximum File Size is ". round(($maxsize/1024), 2) . "kb</font><br>\n";
              echo "<font face=\"verdana\" size=\"1\" color=\"#000000\">Your File Size is ". round(($files/1024), 2) . "kb</font><br><br>\n";
                exit();
                }
      $fol = "../assets/upload/".$HTTP_POST_FILES['file']['name'];
        echo $fol;
            if(file_exists($fol)) {
                  die ("<font face=\"verdana\" size=\"1\" color=\"#000000\">File name exist !!</font>");
                         }

                   else {
       copy($_FILES['file']['tmp_name'], "../assets/upload/" . $HTTP_POST_FILES['file']['name']);
         unlink($HTTP_POST_FILES['file']['tmp_name']);
               $oripic= "upload/".$_FILES['file']['name'];
               $size = getImageSize($oripic);
               $imgwidth = $size[0];
               $imgheight = $size[1];
               $ratio = $imgwidth / $imgheight;
               $nratio = $maxwidth / $ratio;
               $newheight = $nratio;
               if($imgwidth > $maxwidth){
                     $quality = 85;
             $thumb = ImageCreateTrueColor ($maxwidth, $newheight);
            $image = ImageCreateFromJpeg($oripic);
             imagecopyresized ($thumb, $image, 0, 0, 0, 0, $maxwidth, $newheight, $imgwidth, $imgheight);
             imagejpeg($thumb, $oripic, $quality);
              imagedestroy($thumb);
             }
       echo "<font face=\"verdana\" size=\"2\" color=\"#000000\"><b>File Uploaded Successfully</b></font><br><br>";
                          }
                     }
                    else {
                       echo "<font face=\"verdana\" size=\"2\" color=\"#000000\"><b>You must specify a file to upload</b></font><br>\n";
                 echo "<font face=\"verdana\" size=\"2\" color=\"#000000\"><a href=\"java script:history.back()\">< < back</a></font><br>\n";
                 exit();
                      }
                  }
?>



<table border="0" width="500" cellspacing="0" cellpadding="0">
    <form action="<?=$HTTP_SERVER_VARS['PHP_SELF'];?>"  method="post" enctype="multipart/form-data">
        <tr>
            <td width="130" height="20" align="left" valign="top"><font color="#000000" face="verdana" size="1">Image To Upload :</font><br></td>
            <td width="370" height="40" align="left" valign="top"><input type="file" size="40" name="file"></td>
        </tr>
        <tr>
            <td colspan="2" height="20" width="500" align="center" valign="top"><input type="submit" name="upload" value="Upload"></td>
        </tr>
    </form>
</table>

    </body>
</html>
 
 

Recent GIDBlogToyota - 2008 July Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VALIDATING file types on an PHP upload script? JdS MySQL / PHP Forum 0 02-Jan-2003 07:58

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:14.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.