2017-05-29 19 views
0

私はこのプラグインを使用しています。私はそれに関する多くの情報を探していました。私は私を助けたいと思います。 1)5000個以上のファイルが渡された場合、jsoneは生成されなくなりました。 これに関して、私はデータベースのIDで呼び出しを行っていましたが、まだfotos.phpを取得していませんか? ID = 1と、そのクエリ 2)これはjquery file upload php database blueimp

class CustomUploadHandler extends UploadHandler { 


protected function initialize() { 
    $this->db = new mysqli(
     $this->options['db_host'], 
     $this->options['db_user'], 
     $this->options['db_pass'], 
     $this->options['db_name'] 
    ); 
    parent::initialize(); 
    $this->db->close(); 
} 

protected function handle_form_data($file, $index) { 
    $file->title = @$_REQUEST['title'][$index]; 
    $file->description = @$_REQUEST['description'][$index]; 
    $file->padre = @$_REQUEST['padre'][$index]; 


} 

protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, 
             $index = null, $content_range = null) { 
    $file = parent::handle_file_upload(
     $uploaded_file, $name, $size, $type, $error, $index, $content_range 
    ); 
    if (empty($file->error)) { 
     $sql = 'INSERT INTO `'.$this->options['db_table'] 
      .'` (`ruta_adjunto`, `id_documento`, `tipo_adjunto`, `nombre_adjunto`, `descripcion_adjunto`)' 
      .' VALUES (?, ?, ?, ?, ?)'; 
     $query = $this->db->prepare($sql); 
     $query->bind_param(
      'sisss', 
      $file->name, 
      $file->padre, //id_documento luego ver como traer el id 
      $file->type, 
      $file->title, 
      $file->description 
     ); 
     $query->execute(); 
     //echo json_encode($query->error); 
     $file->id_adjunto = $this->db->insert_id; 
    } 
    return $file; 
} 


protected function set_additional_file_properties($file) { 
    parent::set_additional_file_properties($file); 
    if ($_SERVER['REQUEST_METHOD'] === 'GET') { 
     $sql = 'SELECT `id_adjunto`, `id_documento`, `ruta_adjunto`, `nombre_adjunto`, `descripcion_adjunto` FROM `' 
      .$this->options['db_table'].'` WHERE `ruta_adjunto`=?'; 
     $query = $this->db->prepare($sql); 
     $query->bind_param('s', $file->name); 
     $query->execute(); 
     $query->bind_result(
      $id_adjunto, 
      $id_documento, 
      $titulo_documento, 
      $descripcion_documento 
     ); 
     while ($query->fetch()) { 
      $file->id = $id_adjunto; 
      //$file->type = $type; 
      $file->padre = $id_documento; 
      $file->title = $titulo_documento; 
      $file->description = $descripcion_documento; 
     } 
    } 
} 

public function delete($print_response = true) { 
    $response = parent::delete(false); 
    foreach ($response as $name => $deleted) { 
     if ($deleted) { 
      $sql = 'DELETE FROM `' 
       .$this->options['db_table'].'` WHERE `ruta_adjunto`=?'; 
      $query = $this->db->prepare($sql); 
      $query->bind_param('s', $name); 
      $query->execute(); 
     } 
    } 
    return $this->generate_response($response, $print_response); 
} 
/server/php/index.phpに配置され、私のPHPファイルであるデータベース

ですでにデータ アップデートを更新するJSONを生成するだけで

}

$ upload_handler = new CustomUploadHandler($ options);

私はしませんがだから私は

{% for (var i=0, file; file=o.files[i]; i++) { %} 

<tr class="template-upload fade"> 
    <td> 
     <span class="preview"></span> 
    </td> 
    <td> 
    <label class="title"> 
     <span>Nombre:</span><br> 
     <input name="title[]" class="form-control"> 
     </label> 
    </td> 
    <td> 
    <label class="description"> 
     <span>Descripcion:</span><br> 
     <input name="description[]" class="form-control"> 
     </label> 
     <input name="padre[]" value="<?php echo $_GET['id'];?>" class="form-control"> 
    </td> 
    <td> 
     <p class="name">{%=file.name%}</p> 
     <strong class="error text-danger"></strong> 
    </td> 
    <td> 
     <p class="size">Procesando...</p> 
     <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div> 
    </td> 
    <td> 
     {% if (!i && !o.options.autoUpload) { %} 
      <button class="btn btn-primary start" disabled> 
       <i class="glyphicon glyphicon-upload"></i> 
       <span>Comenzar</span> 
      </button> 
     {% } %} 
     {% if (!i) { %} 
      <button class="btn btn-warning cancel"> 
       <i class="glyphicon glyphicon-ban-circle"></i> 
       <span>Cancelar</span> 
      </button> 
     {% } %} 
    </td> 
</tr> 

ここで{%}%}

いくつかの参照

Reference 1

Reference 2

答えて

0

upload.htmlファイルを持っていますuser_dirsを使うのが最善の解決策だと思ってください。ファイルサーバ/php/UploadHandler.php

Fこのライン上でこの

'user_dirs' => true, 
upload.htmlファイルで

session_start(); $_SESSION['father'] = $_GET['id']; 

そして/サーバー/ PHP /インデックスのようにそれを残します。 PHP

protected function get_user_id() { 
    @session_start(); 

    foreach($_SESSION as $key=>$father) { 
     $username = $father; 
    } 
    return $username; 

    #return session_id(); 
} 

これは、IDをセッションとして渡し、割り当てられたフォルダを表示することです。

私はすべてのファイルが一緒にいたフォルダを持っていますが、ファイルにID番号でフォルダを作成する小さなスクリプトを作る

<?php 

ますrequire_once(「../inc/conexion.php」 );

$ db = db :: getInstance();

$ res = $ db-> query( "SELECT * FROM adjuntos LIMIT 2000");

$ ruta = '../admin/server/php/files/';

ながら($ REG = $ RES-> fetch_array()){

if(file_exists($ruta.$reg['id_documento'])){ 
    $origen = '../pdfs/'.$reg['ruta_adjunto']; 
    $destino = $ruta.$reg['id_documento'].'/'.$reg['ruta_adjunto']; 
    if(!copy($origen, $destino)){ 
     echo 'error al copiar el archivo del id: '.$reg['id_documento']; 
    } 
}else{ 
    $carpeta = $ruta.$reg['id_documento']; 
    if(!mkdir($carpeta, 0777, true)){ 
     echo 'Error al crear la CARPETA CON ID: '.$reg['id_documento']; 
    }else{ 
     $origen = '../pdfs/'.$reg['ruta_adjunto']; 
     $destino = $ruta.$reg['id_documento'].'/'.$reg['ruta_adjunto']; 
     if(!copy($origen, $destino)){ 
      echo 'error al copiar el archivo del id: '.$reg['id_documento']; 
     } 
    } 
} 

}?>

関連する問題