<?php require_once "phpuploader/include_phpuploader.php"; ?> <?php $uploader = new PhpUploader(); $mvcfile = $uploader->GetValidatingFile(); if ($mvcfile->FileName == "accord.bmp") { $uploader->WriteValidationError("My custom error : Invalid file name. "); exit(200); } //USER CODE: $productId = $_REQUEST["proId"]; $imageType = $_REQUEST["imgType"]; $savefilepath = "data/" . $productId . "_" . $imageType . "." . substr(strrchr($mvcfile->FileName, '.'), 1); $targetfilepath = "../../" . $savefilepath; if (is_file($targetfilepath)) { unlink($targetfilepath); } $mvcfile->MoveTo($targetfilepath); $uploader->WriteValidationOK(); require_once "../../controller/ProductImageController.php"; ProductImageController::Update($productId, $imageType, $savefilepath); ?>
<?php require_once "include_phpuploader.php"; require_once "smart_resize_image.function.php"; set_time_limit(3600); $uploader = new PhpUploader(); $uploader->PreProcessRequest(); $mvcfile = $uploader->GetValidatingFile(); if ($mvcfile->FileName == "thisisanotvalidfile") { $uploader->WriteValidationError("My custom error : Invalid file name. "); exit(200); } if ($uploader->SaveDirectory) { if (!$uploader->AllowedFileExtensions) { $uploader->WriteValidationError("When using SaveDirectory property, you must specify AllowedFileExtensions for security purpose."); exit(200); } $cwd = getcwd(); chdir(dirname($uploader->_SourceFileName)); if (!is_dir($uploader->SaveDirectory)) { $uploader->WriteValidationError("Invalid SaveDirectory ! not exists."); exit(200); } chdir($uploader->SaveDirectory); $wd = getcwd(); chdir($cwd); $targetfilepath = "../uploads/" . $mvcfile->FileName; if (file_exists($targetfilepath)) { unlink($targetfilepath); } $mvcfile->CopyTo($targetfilepath);