I have spent a long time trying to get this to work, and there is not enough documentation on how to mak it work. I cannot even get the samples to work on my server.
When I click “add file” and then “upload” nothing happens, I just get the word “ERROR”. So I have no idea why it wont work.
The page I am trying to implament this on is in a folder called “admin”, which is placed in my site root.
I have tried placing the “handlers” folder in my site root, my server root, and the “admin” folder. I have tried many different values for the “target_path” variable in “UploadHandler.php” and have tried placing the target upload folder in may different locations.
This is not a permissions fault, I am sure of that.
I have also tried placing the codebase folder in the site root too.
So my questions are:
-
Does the “handlers” folder and “codebase” folders NEED to be in my site root?
-
Should I remove the “php” folder in “handlers” and just have the php files in the “handlers” folder?
-
What is the “target_path” variable relative to? - I have even tried using an absolute path for this.
-
Is there some debugging mode or logs I can use to actually identify the problem, like in the other dhtmlx components, the word “ERROR” is no use.
Here is my code:
included files:
[code]
[/code]Javascript:
vault=new dhtmlXVaultObject();
vault.setImagePath("codebase/imgs_vault/");
vault.setServerHandlers("UploadHandler.php",
"GetInfoHandler.php",
"GetIdHandler.php");
vault.setFilesLimit(3);
vault.onAddFile = function(fileName) {
var ext = this.getFileExtension(fileName);
if (ext != "jpg" && ext != "png" && ext != "gif") {
alert("You may upload image files: .jpg, .gif, .png");
return false;
}
else return true;
};
vault.create("vaultDiv");
UploadHandler.php - When the “handlers” folder is placed one directory down from root (“admin” folder):
<?php //require_once('../Connections/base_href.php');
//echo $_SERVER['DOCUMENT_ROOT'];
$id = $_GET['sessionId'];
$id = trim($id);
session_name($id);
session_start();
$inputName = $_GET['userfile'];
$fileName = $_FILES[$inputName]['name'];
$tempLoc = $_FILES[$inputName]['tmp_name'];
echo $_FILES[$inputName]['error'];
//$target_path = $base_href.'images/products/';
//$target_path = 'images/products/';
//$target_path = '../../images/products/';
//$target_path = $_SERVER['DOCUMENT_ROOT'].'/images/products/';
$target_path = '../images/products/';
$target_path = $target_path . basename($fileName);
if(move_uploaded_file($tempLoc,$target_path))
{
$_SESSION['dhxvlt_state'] = -1;
} else {
$_SESSION['dhxvlt_state'] = -3;
}
?>
Thanks in advance