-
-
- session_start();
- if($_SESSION['Company']=='')
- {
- //exit();
- }
- ?>
- < ;?php //Upload pictures
- $uptypes=array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif','image/bmp',' application/x-shockwave-flash','image/x-png');
- $max_file_size=5000000; //Upload file size limit, unit BYTE
$addtime=date("Ymd" ,time());
- $testdir="./".$addtime."/";
- if(file_exists($testdir)):
- else:
- mkdir($testdir,0777);
- endif;
- $destination_folder =$addtime."/"; //Upload file path
- $imgpreview=1; //Whether to generate a preview image (1 is generated, others are not generated);
- $imgpreviewsize=1/2; //Thumbnail image ratio
- if ($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- if (!is_uploaded_file($_FILES["Pic"][tmp_name]))
- //Whether the file exists
- {
- echo "File does not exist! ";
- exit;
- }
- $file = $_FILES["Pic"];
- if($max_file_size < $file["size"])
- //Check the file size
- {
- echo "The file is too big!";
- exit;
- }
- if(!in_array($file["type"], $uptypes))
- //Check the file type
- {
- echo "Only image files or Flash can be uploaded!";
- exit;
- }
- if(!file_exists ($destination_folder))
- mkdir($destination_folder);
- $filename=$file["tmp_name"];
- $image_size = getimagesize($filename);
- $pinfo=pathinfo($file["name"]);
- $ftype=$pinfo[extension];
- $PicName = time().".".$ftype;
- $destination = $destination_folder.$PicName;
- if (file_exists($destination) && $overwrite != true)
- {
- echo "The file with the same name already exists! ";
- exit;
- }
- if(!move_uploaded_file ($filename, $destination))
- {
- echo "Error uploading file! ";
- exit;
- }
- $pinfo=pathinfo($destination);
- $fname=$pinfo[basename];
- }
- ?>
- $path = dirname(__FILE__);
- require_once($path.'/../../Module/Factory.php');
- $Factory = new Factory();
- $BLL_Trade = $Factory->FactoryTrade();
- try {
- $Infor = new Infor();
- $Infor->Title = $_POST['Title'];
- $Infor->Deposit = $_POST['Deposit'];
- $Infor->Hire = $_POST[' Hire'];
- $Infor->Location = $_POST['Location'];
- $Infor->Pic = $destination;
- $Infor->Intro = $_POST['Intro'];
- if( $_SESSION['MemberId'] ==''){
- $Infor->Member->ID='';
- }else {
- $Infor->Member->ID = $_SESSION['MemberId' ];}
- if($_POST['GoodsBarCode'] ==''){
- $Infor->Goods->BarCode = 0;
- }else {
- $Infor->Goods->BarCode = $ _POST['GoodsBarCode'];}
- $Infor->Class->ID = 0;//Modify later
- $Infor->IssueTime = time();
- $Infor->ViewNum = 0;
- $ Infor->State = 1; //Undecided now, will be modified in the future
- $Infor->Top = 0;
- $Infor->Recommend = 0;
- $Infor->BookMember->ID = 0;
- $Infor->BookTime = 0;
- $Infor->BookRemark = 0;
- $BLL_Trade->CreateInfor($Infor);
- echo 'Publish information successfully! ';
- }
- catch (Exception $Err){
- echo $Err->getMessage();
- }
- ?>
-
Copy code
PHP file upload function code example
How to set the upload size of PHP files
php file upload code collection (example sharing)
PHP file upload comprehensive example sharing
Examples of php file upload (normal upload and asynchronous upload)
Example analysis of php file upload
Analysis of php file upload example
PHP single file upload example analysis
Simple example analysis of php multiple file upload
In-depth analysis and understanding of PHP file upload principles
php file upload simple example
Simple example of php file upload
Understand the principles of PHP file upload
PHP increases file upload size limit
How to set up php to allow large file uploads
Share a PHP file upload class
php code to implement file upload
|