public function postAction() { if (!Mage::helper('customer')->isLoggedIn()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/create')); } else { //die(var_dump($_FILES)); $userid = Mage::getSingleton('customer/session')->getCustomer()->getId(); include Mage::getBaseDir('lib') . "/easy_upload/upload_class.php"; //classes is the map where the class file is stored $max_size = 1024 * 100; // the max. size for uploading $upload = new file_upload(); $upload->upload_dir = Mage::getBaseDir('media') . DS . 'surgery' . DS; $upload->extensions = array('.png', '.jpg', '.gif', '.tiff'); // specify the allowed extensions here $upload->rename_file = true; if (!empty($_FILES)) { $upload->the_temp_file = $_FILES['userfile']['tmp_name']; $upload->the_file = $_FILES['userfile']['name']; $ext = strtolower(strrchr($_FILES['userfile']['name'], '.')); $upload->http_error = $_FILES['userfile']['error']; $upload->do_filename_check = 'y'; // use this boolean to check for a valid filename $imagename = $userid . '_' . $this->generate_random_string(); if ($upload->upload($imagename)) { echo '<div id="status">success</div>'; echo '<div id="message">Successfully Uploaded</div>'; //return the upload file echo '<div id="uploadedfile">' . $_FILES['upload']['name'] . '</div>'; $this->save_in_db($userid, $imagename . $ext); } else { echo '<div id="status">failed</div>'; echo '<div id="message">' . $upload->show_error_string() . '</div>'; } } } // if user logged in }
function upload() { $response = $this->response; $form = $response->get_form('upload', 'true'); $form->box_css = 'htmlobject_box'; $form->display_errors = false; $submit = $form->get_elements('submit'); $submit->handler = 'onclick="wait();"'; $form->add($submit, 'submit'); $d['upload_1']['label'] = $this->lang['public_key']; $d['upload_1']['object']['type'] = 'input'; $d['upload_1']['object']['attrib']['type'] = 'file'; $d['upload_1']['object']['attrib']['name'] = 'upload_1'; $d['upload_1']['object']['attrib']['size'] = 30; $d['upload_2']['label'] = $this->lang['server_license']; $d['upload_2']['object']['type'] = 'input'; $d['upload_2']['object']['attrib']['type'] = 'file'; $d['upload_2']['object']['attrib']['name'] = 'upload_2'; $d['upload_2']['object']['attrib']['size'] = 30; $d['upload_3']['label'] = $this->lang['client_license']; $d['upload_3']['object']['type'] = 'input'; $d['upload_3']['object']['attrib']['type'] = 'file'; $d['upload_3']['object']['attrib']['name'] = 'upload_3'; $d['upload_3']['object']['attrib']['size'] = 30; $form->add($d); if (!$form->get_errors() && $response->submit()) { $upload = new file_upload($this->openqrm->file()); $upload->lang = $this->openqrm->user()->translate($upload->lang, $this->openqrm->get('basedir') . "/web/base/lang", 'file.upload.ini'); $error = ''; for ($i = 1; $i < 4; $i++) { if ($_FILES['upload_' . $i]['name'] !== '') { $msg = $upload->upload('upload_' . $i, $this->openqrm->get('webdir') . '/tmp/', '', true); if ($msg !== '') { $error .= $msg['msg'] . '<br>'; } } } if ($error !== '') { $_REQUEST['upload_msg'] = $error; } else { $response_msg = array(); for ($i = 1; $i < 4; $i++) { if ($_FILES['upload_' . $i]['name'] !== '') { $command = $this->openqrm->get('basedir') . "/bin/openqrm license -l " . $this->openqrm->get('webdir') . "/tmp/" . $_FILES['upload_' . $i]['name'] . " --openqrm-cmd-mode background"; $resource = new resource(); $resource->get_instance_by_id(0); $resource->send_command($resource->ip, $command); $response_msg[] = sprintf($this->lang['msg'], $_FILES['upload_' . $i]['name']); sleep(4); } } $response_msg = implode('<br>', $response_msg); $response->redirect($this->openqrm->get('baseurl') . '/index.php?datacenter_msg=' . $response_msg . '&upload_msg=' . $response_msg); } } $t = $this->response->html->template($this->openqrm->get('webdir') . '/tpl/upload.tpl.php'); $t->add($response->html->thisfile, 'thisfile'); $t->add($this->lang['label'], 'label'); $t->add($this->lang['welcome'], 'welcome'); $t->add($this->lang['explanation'], 'explanation'); $t->add($form->get_elements()); $t->group_elements(array('param_' => 'form')); $content['label'] = $this->lang['tab']; $content['value'] = $t; $content['target'] = $this->response->html->thisfile; $content['request'] = $this->response->get_array('upload', 'true'); $content['onclick'] = false; $content['active'] = true; return $content; }
$my_upload->upload_dir = "../../../videos/"; // "files" is the folder for the uploaded files (you have to create this folder) $my_upload->extensions = array(".jpeg", ".gif", ".bmp",".jpg",".png");// specify the allowed extensions here // $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!) $my_upload->max_length_filename = 50; // change this value to fit your field length in your database (standard 100) $my_upload->rename_file = true; $my_upload->the_temp_file = $_FILES['image']['tmp_name']; $my_upload->the_file = $_FILES['image']['name']; $my_upload->http_error = $_FILES['image']['error']; $my_upload->replace = 'y'; //$my_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true //$my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename $new_name = 'Videos'.GetSID(7); //$new_name = (isset($_POST['name'])) ? $_POST['name'] : ""; if ($my_upload->upload($new_name)) { // new name is an additional filename information, use this to rename the uploaded file $full_path = $my_upload->upload_dir.$my_upload->file_copy; $info = $my_upload->get_uploaded_file_info($full_path); // ... or do something like insert the filename to the database } } else { $full_path = ""; } $_POST = sanitize($_POST); $photos = $_POST; settype($photos,'object'); VideoGallery::updateVideoGallery($photos,$full_path); $success = "Videos Successfully Saved!"; $updates = 'Update videos content';
$my_upload->rename_file = true; if (isset($_POST['Realizar'])) { $tmpFile = trim($_FILES['upload']['name']); $newFile = $valRadio; $uploadDir = "{$ruta_raiz}/bodega/" . substr($valRadio, 0, 4) . "/" . substr($valRadio, 4, 3) . "/"; $fileGrb = substr($valRadio, 0, 4) . "/" . substr($valRadio, 4, 3) . "/{$valRadio}" . "." . substr($tmpFile, -3); $my_upload->upload_dir = $uploadDir; $my_upload->the_temp_file = $_FILES['upload']['tmp_name']; $my_upload->the_file = $_FILES['upload']['name']; $my_upload->http_error = $_FILES['upload']['error']; $my_upload->replace = isset($_POST['replace']) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true $my_upload->do_filename_check = isset($_POST['check']) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename //$new_name = (isset($_POST['name'])) ? $_POST['name'] : ""; if ($my_upload->upload($newFile)) { // new name is an additional filename information, use this to rename the uploaded file $full_path = $my_upload->upload_dir . $my_upload->file_copy; $info = $my_upload->get_uploaded_file_info($full_path); // ... or do something like insert the filename to the database } else { die("<table class=borde_tab><tr><td class=titulosError>Ocurrio un Error la Fila no fue cargada Correctamente <p>" . $my_upload->show_error_string() . "<br><blockquote>" . nl2br($info) . "</blockquote></td></tr></table>"); } } ?> <table cellspace=2 WIDTH=60% id=tb_general align="left" class="borde_tab"> <tr> <td colspan="2" class="titulos4">ACCION REQUERIDA --> <?php echo $causaAccion; ?> </td>
$upload->upload_dir = '../uploads/hotel-gal/'; $upload->extensions = array('.png', '.jpg'); // specify the allowed extensions here $upload->rename_file = true; $image_list = array(); $hotel_file_id = $_REQUEST['hotel_file_id']; if (!empty($_FILES) && $hotel_file_id != '') { $upload->the_temp_file = $_FILES['userfile']['tmp_name']; $upload->the_file = $_FILES['userfile']['name']; $upload->http_error = $_FILES['userfile']['error']; $upload->do_filename_check = 'y'; // use this boolean to check for a valid filename $upload->hotel_image_id = $hotel_file_id . '_' . $_FILES['userfile']['name']; if ($upload->upload()) { echo '<div id="status">success</div>'; echo '<div id="message">' . $upload->file_copy . ' Successfully Uploaded</div>'; //return the upload file echo '<div id="uploadedfile">' . $upload->file_copy . '</div>'; //---------------thumbanail------------------- $src = "../uploads/hotel-gal/" . $upload->file_copy; $dest = "../uploads/hotels/thumbnails/" . $upload->file_copy; $desired_width = 205; /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */
$my_upload->extensions = array(".png", ".zip", ".pdf"); // specify the allowed extensions here // $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!) $my_upload->max_length_filename = 50; // change this value to fit your field length in your database (standard 100) $my_upload->rename_file = true; if (isset($_POST['Submit'])) { $my_upload->the_temp_file = $_FILES['upload']['tmp_name']; $my_upload->the_file = $_FILES['upload']['name']; $my_upload->http_error = $_FILES['upload']['error']; $my_upload->replace = isset($_POST['replace']) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true $my_upload->do_filename_check = isset($_POST['check']) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename $new_name = isset($_POST['name']) ? $_POST['name'] : ""; if ($my_upload->upload($new_name)) { // new name is an additional filename information, use this to rename the uploaded file $full_path = $my_upload->upload_dir . $my_upload->file_copy; $info = $my_upload->get_uploaded_file_info($full_path); // ... or do something like insert the filename to the database } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Upload example</title> <style type="text/css">
return $oldest; } $max_size = 1024 * 80 * 1024; // the max. size for uploading $my_upload = new file_upload(); $my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/files/"; // "files" is the folder for the uploaded files (you have to create this folder) $my_upload->extensions = array(".png", ".zip", ".pdf", ".gif", ".bmp"); // specify the allowed extensions here if (isset($_POST['Submit'])) { $my_upload->the_temp_file = $_FILES['upload']['tmp_name']; $my_upload->the_file = $_FILES['upload']['name']; $my_upload->http_error = $_FILES['upload']['error']; $my_upload->replace = isset($_POST['replace']) ? $_POST['replace'] : "n"; $my_upload->do_filename_check = isset($_POST['check']) ? $_POST['check'] : "n"; if ($my_upload->upload()) { $latest = get_oldest_file($folder); del_file($folder . $latest); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Demo: File upload/download and open directory</title> <style type="text/css"> <!--
function upload() { $response = $this->get_response(); $form = $response->form; $form->display_errors = true; $file_permission = $response->html->request()->get('permission'); switch ($file_permission) { case 'private': $s3_permission = S3::ACL_PRIVATE; break; case 'public-read': $s3_permission = S3::ACL_PUBLIC_READ; break; case 'public-read-write': $s3_permission = ACL_PUBLIC_READ_WRITE; break; case 'authenticated-read': $s3_permission = ACL_AUTHENTICATED_READ; break; default: $s3_permission = S3::ACL_PRIVATE; break; } if (!$form->get_errors() && $this->response->submit()) { $errors = array(); require_once $this->openqrm->get('webdir') . '/class/file.handler.class.php'; require_once $this->openqrm->get('webdir') . '/class/file.upload.class.php'; $file = new file_handler(); $upload = new file_upload($file); $error = $upload->upload('upload', $this->openqrm->get('webdir') . '/tmp'); if ($error !== '') { $response->error = 'Error uploading ' . $error['msg'] . ' - ' . $this->openqrm->get('webdir') . '/tmp'; } else { $uploaded_file = $this->openqrm->get('basedir') . "/web/base/tmp/" . $_FILES['upload']['name']; $upload_name = basename($uploaded_file); $this->s3->putObject($this->s3->inputFile($uploaded_file, false), $this->bucket_name, $upload_name, $s3_permission); unlink($uploaded_file); $response->msg = 'uploaded ' . $uploaded_file; } } return $response; }
function agregaArchivo($tipoAyuda) { try { include_once "../../include/db/ConnectionHandler.php"; include "../../config.php"; include "../../include/upload/upload_class.php"; $db = new ConnectionHandler("../.."); $db->conn->SetFetchMode(ADODB_FETCH_ASSOC); $sql = "select * from anexos_tipo"; $rs = $db->conn->Execute($sql); while (!$rs->EOF) { $ext[] = "." . $rs->fields["ANEX_TIPO_EXT"]; $rs->moveNext(); } $my_upload = new file_upload(); $my_upload->language = "es"; $my_upload->extensions = $ext; //$my_upload->upload_dir = "../$carpetaBodega/tmp/"; // "files" is the folder for the uploaded files (you have to create this folder) $my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100) $newFile = trim(ucwords(strtolower($_FILES['filePlantilla']['name']))); $uploadDir = "../../{$carpetaBodega}/Ayuda/" . strtolower($this->arrayTpAyuda[$tipoAyuda]) . "/"; $my_upload->upload_dir = $uploadDir; $my_upload->the_temp_file = $_FILES['filePlantilla']['tmp_name']; $my_upload->the_file = $newFile; $my_upload->http_error = $_FILES['filePlantilla']['error']; $my_upload->do_filename_check = isset($_POST['check']) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename if ($i == 0) { if ($my_upload->upload($newFile)) { // new name is an additional filename information, use this to rename the uploaded file $full_path = $my_upload->upload_dir . $my_upload->file_copy; $info = $my_upload->get_uploaded_file_info($full_path); // ... or do something like insert the filename to the database } else { $this->error = "<table width='31%' align='center' cellpadding='0' cellspacing='5' class='borde_tab'><tr><td class=titulosError>Ocurrió un error al subir el archivo: <p>" . $my_upload->show_error_string() . "<br><blockquote>" . nl2br($info) . "</blockquote></td></tr></table>"; } } else { if (!is_dir($uploadDir)) { if (mkdir($uploadDir, 0777, true)) { copy($full_path, $uploadDir . $newFile); } } else { copy($full_path, $uploadDir . $newFile); } } } catch (Exception $e) { $this->error = "Ocurrió un error al subir el archivo: " . $e->getMessage(); } }
continue; } $arFieldValuesUpdate[$k] = $v; } $arConditions = array("id" => $id); $objPhotos->update($table, $arFieldValuesUpdate, $arConditions); $_SESSION['empMsg'] = "Photo Record Updated Successfully"; } if (isset($_FILES['file_name']) && $_FILES['file_name']['name'] != "") { //require_once("../lib/class.image_upload.php"); //require_once("../lib/class.image_resize.php"); require "../lib/class.upload.php"; $objUpload = new file_upload(); $image_height = 320; $image_width = 400; $arfilename = $objUpload->upload($id, 'file_name', IMAGE_UPLOAD_PATH, 'jpeg,gif,png,JPG,JPEG,jpeg'); $objUpload->smart_resize_image(IMAGE_UPLOAD_PATH . $arfilename[0], $image_width, $image_height, IMAGE_UPLOAD_PATH, false, $arfilename[0], true); $filename = $arfilename[0]; /* $objImageupload = new imageFileUpload(); $objImageupload->tag_name = "file_name"; $a_tempFileName = explode(".",strtolower($_FILES['file_name']['name'])); $objImageupload->file_name = $a_tempFileName[0].".".$a_tempFileName[1]; $newFileName = $objImageupload->file_name; $objImageupload->storing_directory = IMAGE_UPLOAD_PATH;
function image_upload($file) { if ($_FILES[$file]['name']) { $max_size = 100000 * 100000; // the max. size for uploading $upload_img = new file_upload(); $upload_img->upload_dir = 'images/'; // "files" is the folder for the uploaded files (you have to create this folder) $upload_img->extensions = array(".jpg"); // specify the allowed extensions here $upload_img->max_length_filename = 1000; // change this value to fit your field length in your database (standard 100) $upload_img->rename_file = true; $upload_img->the_temp_file = $_FILES[$file]['tmp_name']; $upload_img->the_file = $_FILES[$file]['name']; $upload_img->http_error = $_FILES[$file]['error']; if ($upload_img->upload()) { // new name is an additional filename information, use this to rename the uploaded file $full_path = $upload_img->upload_dir . $upload_img->file_copy; $imagename = $upload_img->get_uploaded_file_info($full_path); } } else { $imagename = ""; } return $imagename; }
$form = $response->get_form(); $form->box_css = 'htmlobject_box'; $form->display_errors = true; $d['upload']['label'] = $lang['upload']; $d['upload']['object']['type'] = 'input'; $d['upload']['object']['attrib']['type'] = 'file'; $d['upload']['object']['attrib']['name'] = 'upload'; $d['upload']['object']['attrib']['size'] = 30; $form->add($html->thisfile, 'thisfile'); $form->add($d); if (!$form->get_errors() && $response->submit()) { require_once $RootDir . 'class/file.handler.class.php'; require_once $RootDir . 'class/file.upload.class.php'; $file = new file_handler(); $upload = new file_upload($file); $error = $upload->upload('upload', $RootDir . 'tmp'); if ($error !== '') { $form->set_error('upload', $error['msg']); } else { $resource_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/bin/openqrm license -l " . $OPENQRM_SERVER_BASE_DIR . "/openqrm/web/base/tmp/" . $_FILES['upload']['name'] . " --openqrm-cmd-mode background"; $resource = new resource(); $resource->get_instance_by_id(0); $resource->send_command($resource->ip, $resource_command); $response_msg = sprintf($lang['msg'], $_FILES['upload']['name']); sleep(4); $response->redirect('/openqrm/base/index.php?datacenter_msg=' . $response_msg); } } $tpl = $html->template($RootDir . 'tpl/upload.tpl.php'); $tpl->add($html->thisurl, 'baseurl'); $tpl->add($lang['label'], 'label');