Mysql
 sql >> Database >  >> RDS >> Mysql

Carica file Ajax PHP

Nel tuo Javascript fai

$(function(){
        var btnUpload=$('#me');
        var mestatus=$('#mestatus');
        var files=$('#files');
        new AjaxUpload(btnUpload, {
            action: '../UploadDoc/Upload.php',
            name: 'uploadfile',
            params: {
                  pageKey: 'HtmlPage1_'
            }
      ......ETC-CODE......................

OPPURE il tuo codice javascript lo fa

$(function(){
        var btnUpload=$('#me');
        var mestatus=$('#mestatus');
        var files=$('#files');
        new AjaxUpload(btnUpload, {
            action: '../UploadDoc/Upload.php?pageKey=HtmlPage1_',
            name: 'uploadfile',
      ......ETC-CODE......................

E nel tuo PHP fai :

<?php
/* Set the location to upload the file to */
$uploaddir = '../documents/userdocs/'; 

/* Set the name and file extension of the file being saved */
$file = $uploaddir .$_REQUEST['pageKey'].basename($_FILES['uploadfile']['name']); 
$file_name= $_REQUEST['pageKey'].$_FILES['uploadfile']['name']; 
......ETC-CODE......................

Quindi modifichi il tuo codice javascript in ogni pagina in un parametro "pageKey".