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 passing a value from these pages to the Upload.php file, without having to create individual Upload.php files for each web page.
Section of the javascript:
<script type="text/javascript" >
$(function(){
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
new AjaxUpload(btnUpload, {
action: '../UploadDoc/Upload.php',
name: 'uploadfile',
Section of the Upload.php file i would like to pass value to:
<?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 ."HtmlPage1_".basename($_FILES['uploadfile']['name']);
$file_name= "HtmlPage1_".$_FILES['uploadfile']['name'];
Where ‘HtmlPage1_’ will be the information i need to pass in, as it is the only part that changes.
Any help much appreciated.
Many thanks
In your Javascript do
OR your javascript code do
And in your PHP do :
Then you modify your javascript code in each page to a “pageKey” parameter.