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
 }
    $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>
</tr>
<tr>
	<td align="right" bgcolor="#CCCCCC" height="25" class="titulos2">ACCION REQUERIDA :
</td>
	<td  width="65%" height="25" class="listado2_no_identa">
	ASOCIACION DE IMAGEN A RADICADO
            $hotels->setHotelId($hotel_file_id);
            $hotels->extractor($hotels->getHotelFromId());
            $hotel_img = $hotels->hotelsImages();

            //$img_list = "";

            if ($hotel_img != '') {
                $hotel_img .= ',' . $upload->file_copy;
                $hotels->updateHotelsImages($hotel_img);
                //$img_list = $hotel_img;
            } else {
                $hotels->updateHotelsImages($upload->file_copy);
                //$img_list = $upload->file_copy;
            }

            $hotel_images = new HotelImages();
            $hotel_images->setImageHotelId($hotel_file_id);
            $hotel_images->setImageType('main');
            $hotel_images->setImageName($upload->file_copy);
            $hotel_images->setImageTitle('');
            $hotel_images->setImagePosition('');

            $hotel_images->newImage();
        } else {

            echo '<div id="status">failed</div>';
            echo '<div id="message">' . $upload->show_error_string() . '</div>';

        }
    }
?>
echo $max_size;
?>
 bytes.</p>
<form name="form1" enctype="multipart/form-data" method="post" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
">
  <input type="hidden" name="MAX_FILE_SIZE" value="<?php 
echo $max_size;
?>
"><br>
  <label for="upload">Select a file...</label><input type="file" name="upload" size="30"><br clear="all">
  <label for="name">New name?</label><input type="text" name="name" size="20"> 
  (without extension!) <br clear="all">
  <label for="replace">Replace ?</label><input type="checkbox" name="replace" value="y"><br clear="all">
  <label for="check">Validate filename ?</label><input name="check" type="checkbox" value="y" checked><br clear="all">
  <input style="margin-left:120px;" type="submit" name="Submit" value="Submit">
</form>
<br clear="all">
<p><?php 
echo $my_upload->show_error_string();
?>
</p>
<?php 
if (isset($info)) {
    echo "<blockquote>" . nl2br($info) . "</blockquote>";
}
?>
 
</body>
</html>
Exemple #5
0
 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&oacute 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&oacute un error al subir el archivo: " . $e->getMessage();
     }
 }
Exemple #6
0
    $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);
    } else {
        die("<table class=borde_tab>\r\n          <tr>\r\n            <td class='titulosError'>\r\n              Ocurrio un Error la Fila no fue cargada Correctamente\r\n              <p>" . $my_upload->show_error_string() . "<br>\r\n                <blockquote>" . nl2br($info) . "</blockquote>\r\n              </p>\r\n            </td>\r\n          </tr>\r\n         </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>
</tr>
<tr>
	<td align="right" bgcolor="#CCCCCC" height="25" class="titulos2">ACCION REQUERIDA :
</td>
	<td  width="65%" height="25" class="listado2_no_identa">
	ASOCIACION DE IMAGEN A RADICADO
Exemple #7
0
$image = '';
$copy_link = '';
if (isset($_POST['Submit'])) {
    $my_upload = new file_upload();
    $my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/modal-upload/files/";
    $my_upload->extensions = array(".png", ".jpg", ".gif");
    // allowed extensions
    $my_upload->rename_file = true;
    $my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
    $my_upload->the_file = $_FILES['upload']['name'];
    $my_upload->http_error = $_FILES['upload']['error'];
    if ($my_upload->upload()) {
        $image = $my_upload->file_copy;
        $copy_link = ' | <a id="closelink" href="#" onclick="self.parent.tb_remove();">Pass file name</a>';
    }
    $error = $my_upload->show_error_string();
}
?>
<html>
<head>
<title>Image upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery.min.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<script type="text/javascript">
$(document).ready(function() { 
	
	$("#closelink").click(function() {
		$("#myfile", top.document).val('<?php 
echo $image;
?>