- <?php
- $file_types_array=array("jpg");
- $max_file_size=1048576;
- $upload_dir="../guild";
- function uploaderFILES($num_of_uploads=1, $file_types_array=array("JPG"), $max_file_size=1048576, $upload_dir="../guild"){
- if(!is_numeric($max_file_size)){
- $max_file_size = 1048576;
- }
- foreach($_FILES["file"]["error"] as $key => $value)
- {
- if($_FILES["file"]["name"][$key]!="")
- {
- if($value==UPLOAD_ERR_OK)
- {
- $origfilename = $_FILES["file"]["name"][$key];
- $filename = explode(".", $_FILES["file"]["name"][$key]);
- $filenameext = $filename[count($filename)-1];
- unset($filename[count($filename)-1]);
- $filename = implode(".", $filename);
- $filename = substr($filename, 0, 15).".".$filenameext;
- $file_ext_allow = FALSE;
- for($x=0;$x<count($file_types_array);$x++){
- if($filenameext==$file_types_array[$x])
- {
- $file_ext_allow = TRUE;
- }
- } // for
- if($file_ext_allow){
- if($_FILES["file"]["size"][$key]<$max_file_size){
- if(move_uploaded_file($_FILES["file"]["tmp_name"][$key], $upload_dir.$filename)){
- echo('<br><br><font color="blue">'.$filename."</font> was successful <br />");
- }
- else { echo('<br><br><font color="#FF0000">'.$origfilename."</font> was not successfully uploaded <br />");}
- }
- else { echo('<br><br><font color="#FF0000">'.$origfilename."</font> was too big, not uploaded <br />"); }
- } // if
- else{ echo('<br><br><font color="#FF0000">'.$origfilename." </font>had an invalid file extension<br />"); }
- }
- else{ echo('<br><br><font color="#FF0000">'.$origfilename." </font>was not successfully uploaded<br />"); } // else
- }
- }
- } // funtion
- /////////////////////////////////////////
- if(isset($_POST["submitted"])){
- uploaderFILES($num_of_uploads, $file_types_array, $max_file_size, $upload_dir);
- }
- // Close the FTP connection
- ftp_close($conn_id);
- ?>
- <?php
- $imgdir = '../guild'; // the directory, where your images are stored
- $allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
- $dimg = opendir($imgdir);
- while($imgfile = readdir($dimg))
- {
- if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
- {
- $a_img[] = $imgfile;
- sort($a_img);
- reset ($a_img);
- }
- }
- $totimg = count($a_img); // total image number
- for($x=0; $x < $totimg; $x++)
- {
- $size = getimagesize($imgdir.'/'.$a_img[$x]);
- // do whatever
- $halfwidth = ceil($size[0]/2);
- $halfheight = ceil($size[1]/2);
- echo "<img src= '$imgdir/$a_img[$x]'>";
- echo 'link: [url]http://eye-candy-guild.ueuo.com/guild/'.[/url]$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
- }
- ?>
复制代码 |