<?php
/**
 * Created by Noman Shiekh.
 * User: Admin
 * Date: 22/6/2015
 * Time: 11:34 AM
 * @TODO upload PDF
 */

class upload {

    public  static function PDF($file){
       
        $msg = '' ;
        $file_upload="true";

        $file_up_size =  $file['size'];
        // $file['name'];

        $file_type = $file['type'];
        $file_name=$file['name'];
        $temp = explode(".",$file_name);
       // $newfilename = rand(1,99999) . '.' .end($temp);
	$newfilename = $file_name;
        $file_name_tmp = $file['tmp_name'];

        //$file_name1="../../images/hbl.jpg";
        $add="../admin/product_wording/$newfilename"; // the path with the file name where the file will be stored
        list($width, $height) = getimagesize($file_name_tmp);

        if ($file_up_size > 10000000){

            $msg=$msg."Your uploaded file size is more than 10 MB
                         so please reduce the file size and then upload.<br>";
            $file_upload="false";

        }


        /*   if (!($file_type =="application/pdf"))
           {
               $msg=$msg."Your uploaded file must be of PDF. Other file types are not allowed<br>";
               $file_upload="false";


           }


   */


        if($file_upload=="true"){




            /*// Get new dimensions
                        list($width, $height) = getimagesize($file_name_tmp);
                        $new_width = $width >= 220 ? 220 : $width;// $widl;

                        $new_height = $height * ($new_width / $width);

            // resize if necessary
                        if ($width >= 50 && $height >= 50) {
                            $file = new Imagick($file_name_tmp);
                            $file->thumbnailImage(50, 50);
                            $file->writeImage($file_name);
                        }
                     else{

                            $upload=  move_uploaded_file ($file_name_tmp, $add);

                        }*/
            $upload=  move_uploaded_file ($file_name_tmp, $add);

            if($upload){
                // do your coding here to give a thanks message or any other thing.
                $msgs[] ="Upload Successfully!";
                $msgs[] = $newfilename;
                return $msgs;
            }
            else{
                $msg= "Failed to upload file Contact Site admin to fix the problem";

                return $msg;


            }

        }else{
            return $msg;
        }


















    }











}