Skip to content

Instantly share code, notes, and snippets.

@spham
Created December 10, 2019 09:56
Show Gist options
  • Select an option

  • Save spham/b3610c97c02cdf3874eb9ff14ddd709c to your computer and use it in GitHub Desktop.

Select an option

Save spham/b3610c97c02cdf3874eb9ff14ddd709c to your computer and use it in GitHub Desktop.
// upload des images dans un dossiers externe a l'application
public function postAction()
{
$config = Zend_Registry::get(Cadif_Enum_RegistryKeys::CONFIG);
$dossier = $config->application->uploadCommonPath . $_POST['id_contenu']; // dossier avec numero de contenu
$nom_du_fichier_recu = $_FILES["file"]['name'];
$mon_fichier = $dossier . DIRECTORY_SEPARATOR . $nom_du_fichier_recu;
if (!file_exists($dossier)) {
mkdir($dossier, 0777, true);
}
if ( $nom_du_fichier_recu == "screenshot.png" )
{
$img = imagecreatefrompng($_FILES['file']['tmp_name']);
$croppedImage = imagecropauto($img, IMG_CROP_WHITE);
imagepng($croppedImage, $mon_fichier);
imagedestroy($croppedImage);
return true;
}
move_uploaded_file($_FILES['file']['tmp_name'], $mon_fichier);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment