I am trying to create an image uploader however, the code I have created doesn't seem to upload the images. If anyone sees any ways that I can get this to work or if you know any better ways, please let me know.
<?php /*======================================================================*\ || #################################################################### || || # The PHP Store Uploader Beta 1.00 # || || # ---------------------------------------------------------------- # || || # Copyright ©2004 Sean Vasey . All Rights Reserved. # || || # This script may not be redistributed without written consent. # || || # ------------------------ The PHP Store ------------------------- # || || # http://thephpstore.com # || || #################################################################### || \*======================================================================*/ // user defined variables $uploadpath = "/home/midweste/www/www/uploader/uploads"; // absolute path to destination folder $serverpath = "http://midwesternwebs.com/uploader/uploads"; // server path to uploads folder with no trailing slash (ex. http://thephpstore.com/uploads) $sizelimit = "yes"; // do you want a size limit on the upload? (yes or no) $size = "102400"; // if size limit, what is it? (in bytes) $uploads = "1"; // number of uploads (changing this is not recommended) // variables $imagesize = getimagesize($image); // begin checks and upload if successful if ($_REQUEST['submitted']) // if hidden field, submitted, is obtained on request, begin processing { // image mime types $gif = "image/gif"; // gif mime type $jpg = "image/pjpeg"; // jpg mime type $jpeg = "image/jpeg"; // jpeg mime type $png = "image/png"; // png mime type $xpng = "image/x-png"; // png mime type for internet explorer $bmp = "image/bmp"; // bmp mime type $tiff = "image/tiff"; // tiff mime type /* NOTE: You can also add more mime types to those listed above however you will also be required to make some more adjustments to the processing portion of the script where it checks if the submitted image matches the listed mime types. More directions are included in the install.txt and readme.txt files. Please consult them for more details. */ $result = ""; // make sure there is no result at this point $rand = rand(1, 99999); // random number to at at end of filename for ($i = 0; $i < $uploads; $i++) { if (($img[$i] == "$gif") or ($img[$i] == "$jpeg") or ($img[$i] == "$jpg") or ($img[$i] == "$png") or ($img[$i] == "$xpng") or ($img[$i] == "$bmp") or ($img[$i] == "$tiff")) { if ($img[$i] == "$gif") // if gif file type { $image[$i] = $image[$i] . "-" . "$rand" . ".gif"; } if (($img[$i] == "$jpg") or ($img[$i] == "$jpeg")) // if jpeg file type { $image[$i] = $image[$i] . "-" . "$rand" . ".jpg"; } if (($img[$i] == "$png") or ($img[$i] == "$xpng")) // if png file type { $image[$i] = $image[$i] . "-" . "$rand" . ".png"; } if ($img[$i] == "$tiff") // if tiff file type { $image[$i] = $image[$i] . "-" . "$rand" . ".tiff"; } if ($img[$i] == "$bmp") // if bmp file type { $image[$i] = $image[$i] . "-" . "$rand" . ".bmp"; } } } for ($i = 0; $i < $uploads; $i++) { // check if a file was selected for upload if (!$image[$i]) { $result .= "You did not select an image for upload!<br>"; } if ($image[$i]) // if an image was selected, make sure it meets requirements { // check if file already resides on server if (file_exists("$uploadpath/$image[$i]")) { $result .= "The image you attempted to upload already resides on the server. Please rename your image before continuing!<br>"; } // check if the image was too large if ($sizelimit == "yes" && $imagesize > $size) { $result .= "The image you attempted to upload was too large. Please try another image!<br>"; } } else { // check if file is an image one last time if (($img[$i] == "$gif") or ($img[$i] == "$jpeg") or ($img[$i] == "$jpg") or ($img[$i] == "$png") or ($img[$i] == "$xpng") or ($img[$i] == "$bmp") or ($img[$i] == "$tiff")) { @copy($image[$i], "$uploadpath/$image[$i]") or $result .= "$image[$i] could not be copied to the server. Please try again!"; if (file_exists("$uploadpath/$image[$i]")) { $result .= "Your image was successfully uploaded to <a href=\"$serverpath/$image[$i]\" target=\"_blank\">$serverpath/$image[$i]</a><br>"; } else { $result .= "The file you attempted to upload was not an image!<br>"; } } } } } echo($result); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php