/** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * * @param string $sdir Repertoire destination finale * @param string $file Nom du fichier uploade * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos"; dol_mkdir($dir); $dir_osencoded=$dir; if (is_dir($dir_osencoded)) { $originImage = $dir . '/' . $file['name']; // Cree fichier en taille origine $result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1); if (file_exists(dol_osencode($originImage))) { // Cree fichier en taille vignette $this->add_thumb($originImage,$maxWidth,$maxHeight); } } }
} else { if (! preg_match('/\.tgz/i',$original_file)) { $mesg=$langs->trans("ErrorFileMustBeADolibarrPackage"); $error++; } } if (! $error) { @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file); create_exdir($conf->admin->dir_temp.'/'.$original_file); $result=dol_move_uploaded_file($_FILES["fileinstall"]["tmp_name"],$newfile,1,0,$_FILES['fileinstall']['error']); if ($result > 0) { //dol_uncompress($newfile); } } } /* * View */ $wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalaci&omodulon_-_Actualizaci&omodulon'; llxHeader('',$langs->trans("Upgrade"),$wikihelp);
/** * Enter description here ... * * @param string $uploaded_file Uploade file * @param string $name Name * @param int $size Size * @param string $type Type * @param string $error Error * @param string $index Index * @return stdClass */ protected function handleFileUpload($uploaded_file, $name, $size, $type, $error, $index) { $file = new stdClass(); $file->name = $this->trimFileName($name, $type, $index); $file->mime = dol_mimetype($file->name, '', 2); $file->size = intval($size); $file->type = $type; if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0) { $file_path = $this->options['upload_dir'] . $file->name; $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); clearstatcache(); if ($uploaded_file && is_uploaded_file($uploaded_file)) { // multipart/formdata uploads (POST method uploads) if ($append_file) { file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); } else { dol_move_uploaded_file($uploaded_file, $file_path, 1, 0, 0, 0, 'userfile'); } } else { // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } $file_size = filesize($file_path); if ($file_size === $file->size) { $file->url = $this->options['upload_url'] . rawurlencode($file->name); foreach ($this->options['image_versions'] as $version => $options) { if ($this->createScaledImage($file->name, $options)) { $tmp = explode('.', $file->name); $file->{$version . '_url'} = $options['upload_url'] . rawurlencode($tmp[0] . '_mini.' . $tmp[1]); } } } else { if ($this->options['discard_aborted_uploads']) { unlink($file_path); $file->error = 'abort'; } } $file->size = $file_size; $this->setFileDeleteUrl($file); } return $file; }
if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $mesg = '<div class="error">' . $langs->trans("ErrorImportDuplicateProfil") . '</div>'; } else { $mesg = '<div class="error">' . $objimport->error . '</div>'; } } } else { $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("ImportModelName")) . '</div>'; } } if ($step == 3 && $datatoimport) { if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { dol_mkdir($conf->import->dir_temp); $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $fullpath = $conf->import->dir_temp . "/" . $nowyearmonth . '-' . $_FILES['userfile']['name']; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { dol_syslog("File " . $fullpath . " was added for import"); } else { $langs->load("errors"); $mesg = $langs->trans("ErrorFailedToSaveFile"); } } } if ($step == 4 && $action == 'select_model') { // Reinit match arrays $_SESSION["dol_array_match_file_to_database"] = ''; $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); // Load model from $importmodelid and set $array_match_file_to_database // and $_SESSION["dol_array_match_file_to_database"] $result = $objimport->fetch($importmodelid);
private function handle_file_upload($uploaded_file, $name, $size, $type, $error) { $file = new stdClass(); $file->name = basename(stripslashes($name)); $file->mime = dol_mimetype($file->name,'',2); $file->size = intval($size); $file->type = $type; $error = $this->has_error($uploaded_file, $file, $error); if (!$error && $file->name && create_exdir($this->options['upload_dir']) >= 0) { if ($file->name[0] === '.') { $file->name = substr($file->name, 1); } $file_path = $this->options['upload_dir'].$file->name; $append_file = is_file($file_path) && $file->size > filesize($file_path); clearstatcache(); if ($uploaded_file && is_uploaded_file($uploaded_file)) { // multipart/formdata uploads (POST method uploads) if ($append_file) { file_put_contents( $file_path, fopen($uploaded_file, 'r'), FILE_APPEND ); } else { // FIXME problem with trigger dol_move_uploaded_file($uploaded_file, $file_path, 1, 0, 0, 1); } } else { // Non-multipart uploads (PUT method support) file_put_contents( $file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0 ); } $file_size = filesize($file_path); if ($file_size === $file->size) { $file->url = $this->options['upload_url'].rawurlencode($file->name); foreach($this->options['image_versions'] as $version => $options) { if ($this->create_scaled_image($file->name, $options)) { $tmp=explode('.',$file->name); $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); } } } else if ($this->options['discard_aborted_uploads']) { unlink($file_path); $file->error = 'abort'; } $file->size = $file_size; $file->delete_url = $this->options['script_url'] .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; $file->delete_type = 'DELETE'; } else { $file->error = $error; } return $file; }
Header("Location: fiche.php?id=".$id); exit; } if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); $bon = new BonPrelevement($db,""); $bon->fetch($id); if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . $_FILES['userfile']['name'],1) > 0) { $dt = dol_mktime(12,0,0,GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); $bon->set_infotrans($user, $dt, GETPOST("methode")); } Header("Location: fiche.php?id=".$id); exit; } else { dol_syslog("Fichier invalide",LOG_WARNING); $mesg='BadFile'; } }
/** * Get and save an upload file (for example after submitting a new file a mail form). * All information used are in db, conf, langs, user and _FILES. * Note: This function can be used only into a HTML page context. * * @param string $upload_dir Directory where to store uploaded file (note: also find in first part of dest_file) * @param int $allowoverwrite 1=Allow overwrite existing file * @param int $donotupdatesession 1=Do no edit _SESSION variable * @param string $varfiles _FILES var name * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param string $link Link to add * @return void */ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null) { global $db, $user, $conf, $langs; if (!empty($_FILES[$varfiles])) { dol_syslog('dol_add_file_process upload_dir=' . $upload_dir . ' allowoverwrite=' . $allowoverwrite . ' donotupdatesession=' . $donotupdatesession . ' savingdocmask=' . $savingdocmask, LOG_DEBUG); if (dol_mkdir($upload_dir) >= 0) { $TFile = $_FILES[$varfiles]; if (!is_array($TFile['name'])) { foreach ($TFile as $key => &$val) { $val = array($val); } } $nbfile = count($TFile['name']); for ($i = 0; $i < $nbfile; $i++) { // Define $destpath (path to file including filename) and $destfile (only filename) $destpath = $upload_dir . "/" . $TFile['name'][$i]; $destfile = $TFile['name'][$i]; $savingdocmask = dol_sanitizeFileName($savingdocmask); if ($savingdocmask) { $destpath = $upload_dir . "/" . preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask); $destfile = preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask); } $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destpath, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); if (is_numeric($resupload) && $resupload > 0) { global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; if (empty($donotupdatesession)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->add_attached_files($destpath, $destfile, $TFile['type'][$i]); } if (image_format_supported($destpath) == 1) { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheigthsmall, '_small', 50, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); } setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); } else { $langs->load("errors"); if ($resupload < 0) { setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); } else { if (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); } else { setEventMessages($langs->trans($resupload), null, 'errors'); } } } } } } elseif ($link) { if (dol_mkdir($upload_dir) >= 0) { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $linkObject = new Link($db); $linkObject->entity = $conf->entity; $linkObject->url = $link; $linkObject->objecttype = GETPOST('objecttype', 'alpha'); $linkObject->objectid = GETPOST('objectid', 'int'); $linkObject->label = GETPOST('label', 'alpha'); $res = $linkObject->create($user); $langs->load('link'); if ($res > 0) { setEventMessages($langs->trans("LinkComplete"), null, 'mesgs'); } else { setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors'); } } } else { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors'); } }
$object->logo = dol_sanitizeFileName($_FILES['photo']['name']); // Gestion du logo de la société $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (image_format_supported($_FILES['photo']['name'])) { dol_mkdir($dir); if (@is_dir($dir)) { $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); if (! $result > 0) { $errors[] = "ErrorFailedToSaveFile"; } else { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); // Create mini thumbs for company (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); }
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", $_POST["tel"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", $_POST["fax"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", $_POST["mail"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", $_POST["web"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", $_POST["note"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", $_POST["barcode"], 'chaine', 0, '', $conf->entity); if ($_FILES["logo"]["tmp_name"]) { if (preg_match('/([^\\/:]+)$/i', $_FILES["logo"]["name"], $reg)) { $original_file = $reg[1]; $isimage = image_format_supported($original_file); if ($isimage >= 0) { dol_syslog("Move file " . $_FILES["logo"]["tmp_name"] . " to " . $conf->mycompany->dir_output . '/logos/' . $original_file); if (!is_dir($conf->mycompany->dir_output . '/logos/')) { dol_mkdir($conf->mycompany->dir_output . '/logos/'); } $result = dol_move_uploaded_file($_FILES["logo"]["tmp_name"], $conf->mycompany->dir_output . '/logos/' . $original_file, 1, 0, $_FILES['logo']['error']); if ($result > 0) { dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO", $original_file, 'chaine', 0, '', $conf->entity); // Create thumbs of logo (Note that PDF use original file and not thumbs) if ($isimage > 0) { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($conf->mycompany->dir_output . '/logos/' . $original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); if (preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) { $imgThumbSmall = $reg[1]; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); } else { dol_syslog($imgThumbSmall); } // Create mini thumbs for company (Ratio is near 16/9) // Used on menu or for setup page for example
/* * Add file in email form */ if ($_POST['addfile'] || $_POST['addfilehtml']) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp'; if (create_exdir($upload_dir) >= 0) { $resupload=dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0,0,$_FILES['addedfile']['error']); if (is_numeric($resupload) && $resupload > 0) { $mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>'; include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); } else { $langs->load("errors"); if ($resupload < 0) // Unknown error { $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; }
/** * Get and save an upload file (for example after submitting a new file a mail form). * All information used are in db, conf, langs, user and _FILES. * @param upload_dir Directory to store upload files * @param allowoverwrite 1=Allow overwrite existing file * @param donotupdatesession 1=Do no edit _SESSION variable * @return string Message with result of upload and store. */ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=0) { global $db,$user,$conf,$langs,$_FILES; $mesg=''; if (! empty($_FILES['addedfile']['tmp_name'])) { if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],$allowoverwrite,0, $_FILES['addedfile']['error']); if (is_numeric($resupload) && $resupload > 0) { $mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>'; if (empty($donotupdatesession)) { include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); } } else { $langs->load("errors"); if ($resupload < 0) // Unknown error { $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus { $mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; } else // Known error { $mesg = '<div class="error">'.$langs->trans($resupload).'</div>'; } } } } else { $langs->load("errors"); $mesg = '<div class="warning">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("File")).'</div>'; } return $mesg; }
// Logo/Photo save $dir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 1, $object, 'member') . '/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (GETPOST('deletephoto')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileimg = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 1, $object, 'member') . '/photos/' . $object->photo; $dirthumbs = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 1, $object, 'member') . '/photos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); if (@is_dir($dir)) { $newfile = $dir . '/' . dol_sanitizeFileName($_FILES['photo']['name']); if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); // Create mini thumbs for company (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); } } } else { setEventMessages("ErrorBadImageFormat", null, 'errors'); } } else { switch ($_FILES['photo']['error']) {
* Actions */ if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') { $bon = new BonPrelevement($db, ""); $bon->id = $id; $bon->set_credite(); Header("Location: fiche.php?id=" . $id); exit; } if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; $bon = new BonPrelevement($db, ""); $bon->fetch($id); if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'], ".ps") == $bon->ref) { $dir = $conf->prelevement->dir_output . '/receipts'; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 1) > 0) { $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $bon->set_infotrans($user, $dt, GETPOST('methode', 'alpha')); } Header("Location: fiche.php?id=" . $id); exit; } else { dol_syslog("Fichier invalide", LOG_WARNING); $mesg = 'BadFile'; } } if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { $bon = new BonPrelevement($db, ""); $bon->fetch($id); $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $error = $bon->set_infocredit($user, $dt);
/** * Move an uploaded file described into $file array into target directory $sdir. * * @param string $sdir Target directory * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) * @return int <0 if KO, >0 if OK */ function add_photo($sdir, $file) { global $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $result = 0; $dir = $sdir; if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= '/' . get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos"; } else { $dir .= '/' . dol_sanitizeFileName($this->ref); } dol_mkdir($dir); $dir_osencoded = $dir; if (is_dir($dir_osencoded)) { $originImage = $dir . '/' . $file['name']; // Cree fichier en taille origine $result = dol_move_uploaded_file($file['tmp_name'], $originImage, 1); if (file_exists(dol_osencode($originImage))) { // Cree fichier en taille vignette $this->add_thumb($originImage); } } if (is_numeric($result) && $result > 0) { return 1; } else { return -1; } }
/** * \brief Deplace fichier uploade sous le nom $files dans le repertoire sdir * \param sdir Repertoire destination finale * \param $file Nom du fichier uploade * \param maxWidth Largeur maximum que dois faire la miniature (160 par defaut) * \param maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) */ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) { require_once DOL_DOCUMENT_ROOT . "/lib/files.lib.php"; $dir = $sdir . '/' . get_exdir($this->id, 2) . $this->id . "/"; $dir .= "photos/"; if (!file_exists($dir)) { create_exdir($dir); } if (file_exists($dir)) { $originImage = $dir . $file['name']; // Cree fichier en taille origine $result = dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); if (file_exists($originImage)) { // Cree fichier en taille vignette $this->add_thumb($originImage, $maxWidth, $maxHeight); } } }
/** * \brief Ajoute destinataires dans table des cibles * \param mailing_id Id of emailing * \param filterarray Requete sql de selection des destinataires * \return int < 0 si erreur, nb ajout si ok */ function add_to_target($mailing_id,$filtersarray=array()) { global $conf,$langs,$_FILES; require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); // For compatibility with Unix, MS-Dos or Macintosh ini_set('auto_detect_line_endings', true); $cibles = array(); $upload_dir=$conf->mailing->dir_temp; if (create_exdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1, 0, $_FILES['username']['error']); if (is_numeric($resupload) && $resupload > 0) { $cpt=0; //$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>'; //print_r($_FILES); $file=$upload_dir . "/" . $_FILES['username']['name']; $handle = @fopen($file, "r"); if ($handle) { $i = 0; $j = 0; $old = ''; while (!feof($handle)) { $cpt++; $buffer = trim(fgets($handle)); $tab=explode(';',$buffer,4); $email=$tab[0]; $name=$tab[1]; $firstname=$tab[2]; $other=$tab[3]; if (! empty($buffer)) { //print 'xx'.dol_strlen($buffer).empty($buffer)."<br>\n"; $id=$cpt; if (isValidEMail($email)) { if ($old <> $email) { $cibles[$j] = array( 'email' => $email, 'name' => $name, 'firstname' => $firstname, 'other' => $other, 'source_url' => '', 'source_id' => '', 'source_type' => 'file' ); $old = $email; $j++; } } else { $i++; $langs->load("errors"); $this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); } } } fclose($handle); if ($i > 0) { return -$i; } } else { $this->error = $langs->trans("ErrorFaildToOpenFile"); return -1; } dol_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found"); } else { $langs->load("errors"); if ($resupload < 0) // Unknown error { $this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus { $this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; } else // Known error { $this->error = '<div class="error">'.$langs->trans($resupload).'</div>'; } } } ini_set('auto_detect_line_endings', false); return parent::add_to_target($mailing_id, $cibles); }
/** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * * @param string $sdir Repertoire destination finale * @param string $file Nom du fichier uploade * @return void */ function add_photo($sdir, $file) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $dir = $sdir . '/' . get_exdir($this->id, 2, 0, 0, $this, 'category') . $this->id . "/"; $dir .= "photos/"; if (!file_exists($dir)) { dol_mkdir($dir); } if (file_exists($dir)) { $originImage = $dir . $file['name']; // Cree fichier en taille origine dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); if (file_exists($originImage)) { // Cree fichier en taille vignette $this->add_thumb($originImage); } } }
if (!$sortfield) { $sortfield = "name"; } $object = new Account($db); if ($id) { $object->fetch($id); } /* * Actions */ // Envoi fichier if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->fetch($id)) { $upload_dir = $conf->bank->dir_output . "/" . $object->ref; if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); } $mesg = '<div class="ok">' . $langs->trans("FileTransferComplete") . '</div>'; } else { $langs->load("errors"); if ($resupload < 0) { // Unknown error $mesg = '<div class="error">' . $langs->trans("ErrorFileNotUploaded") . '</div>';
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); $result=$ecmdir->fetch($_REQUEST["section"]); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } $relativepath=$ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; if (create_exdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0); if (is_numeric($resupload) && $resupload > 0) { //$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>'; //print_r($_FILES); $result=$ecmdir->changeNbOfFiles('+'); } else { $langs->load("errors"); if ($resupload < 0) // Unknown error { $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus { $mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';