File Upload Ajax Php
I have a piece of javascript that uses Ajax and PHP to upload an image. I am using the javascript in the head section of a few html pages and was wondering if there was a way of p
Solution 1:
In your Javascript do
$(function(){
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
newAjaxUpload(btnUpload, {
action: '../UploadDoc/Upload.php',
name: 'uploadfile',
params: {
pageKey: 'HtmlPage1_'
}
......ETC-CODE......................
OR your javascript code do
$(function(){
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
newAjaxUpload(btnUpload, {
action: '../UploadDoc/Upload.php?pageKey=HtmlPage1_',
name: 'uploadfile',
......ETC-CODE......................
And in your PHP do :
<?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......................
Then you modify your javascript code in each page to a "pageKey" parameter.
Post a Comment for "File Upload Ajax Php"