Jump to content

How to add a progress bar


cgrant

Recommended Posts

below is a working php script to make thumbnails and larger image can someone help me implement a progress loading bar? thanks

 

<form action="<?php echo $_server['php-self'];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
        <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
        <button name="submitimg" type="submitimg" class="submitButton">Upload/Resize Image</button>
</form>
<?php
        if(isset($_POST['submitimg'])){
          if (isset ($_FILES['new_image'])){
              $imagename = $_FILES['new_image']['name'];
              $source = $_FILES['new_image']['tmp_name'];
              $target = "photos/".$imagename;
              move_uploaded_file($source, $target);

              $imagepath = $imagename;
              $save = "photos/" . $imagepath; //This is the new file you saving
              $file = "photos/" . $imagepath; //This is the original file

              list($width, $height) = getimagesize($file) ; 

              $modheight = 350; 

              $diff = $height / $modheight;

              $modwidth = $width / $diff; 
              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 

              $save = "photos/thumbs/" . $imagepath; //This is the new file you saving
              $file = "photos/" . $imagepath; //This is the original file

              list($width, $height) = getimagesize($file) ; 

              $modheight = 100; 

              $diff = $height / $modheight;

              $modwidth = $width / $diff; 
              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0,$modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 
            echo "Large image: <img src='photos/".$imagepath."'><br>"; 
            echo "Thumbnail: <img src='photos/thumbs/".$imagepath."'>"; 

          }
        }
?>

 

I am new with php so if someone can help it would be great, I am just looking for a very simple progress bar

Link to comment
https://forums.phpfreaks.com/topic/192679-how-to-add-a-progress-bar/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.