Total Pageviews

Sunday, June 19, 2011

Assignment 11 - Upload Image

Confused about the file upload_image.php file... was not able to find this file

I'm not sure where to add the following code: 

<?php
      startSession(); # wrapper for session_start()
      if(isset($_SESSION["AdminID"]))
      {# only admins can see 'peek a boo' link:
            echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'] . '">UPLOAD IMAGE</a></div>';
            /*
            # if you wish to overwrite any of these options on the view page,
            # you may uncomment this area, and provide different parameters:                               
            echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'];
            echo '&imagePrefix=m';
            echo '&uploadFolder=upload/';
            echo '&extension=.jpg';
            echo '&createThumb=TRUE';
            echo '&thumbWidth=50';
            echo '&thumbSuffix=_thumb';
            echo '&sizeBytes=100000';
            echo '">UPLOAD IMAGE</a></div>';
            */                                 
           
      }
      if(isset($_GET['msg']))
      {# msg on querystring implies we're back from uploading new image
            $msgSeconds = (int)$_GET['msg'];
            $currSeconds = time();
            if(($msgSeconds + 2)> $currSeconds)
            {//link only visible once, due to time comparison of qstring data to current timestamp
                  echo '<div align="center"><script type="text/javascript">';
                  echo 'document.write("<form><input type=button value=\'IMAGE UPLOADED! CLICK TO VIEW!\' onClick=history.go()></form>")</scr';
                  echo 'ipt></div>';
            }
      }
?>
  Was I supposed to drop it directly below the <td> in the view page? Here's what it looks like anyway...
I also recently had to drop the upload_form.php & upload_form_execute.php in order for the hyperlink "Upload Image" to work properly. Images will reside in the "upload" folder 

Looks like it is working properly
extension should match with the BookId so that the image corresponds with the item. 


Looks like error testing works. It did not allow me to add animated .gif files and files that exceed 1000000 kbs. 


Viola! Image uploading works!




NOTES: 
Although the upload_form.php and the upload_execute.php have the "upload" extension, these files do NOT reside in the "upload" folder. 

- Only thumbnails will show when admin modifies the image in image upload executor.... 




Hourly Log: 
6-18-2011 -- .5 hour spent on uploading files and making sure they show up
                     1.5 hours troubleshooting and trying out code (dropping php code into the right file!!!)
                     1 hour implementing the thumbnail next to the list view page

No comments:

Post a Comment