Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Datei-Upload Ajax PHP

Machen Sie in Ihrem Javascript

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

ODER Ihr Javascript-Code

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

Und in Ihrem PHP:

<?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......................

Dann ändern Sie Ihren Javascript-Code auf jeder Seite in einen "pageKey"-Parameter.