dhtmlx Vault not working, just shows error

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:

  1. Does the “handlers” folder and “codebase” folders NEED to be in my site root?

  2. Should I remove the “php” folder in “handlers” and just have the php files in the “handlers” folder?

  3. What is the “target_path” variable relative to? - I have even tried using an absolute path for this.

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

Update

I began to debug the dhtmlxvault.js file… I placed an alert when the “GetInfoHandler.php” is called via AJAX. The response text was as follows:


<b>Fatal error</b>:  Call to undefined function uploadprogress_get_info() in <b>/var/www/doorsdoorsdoors/admin/handlers/php/GetInfoHandler.php</b> on line <b>29</b>

Thank God I had error handling turned on, on my testing server, otherwise I would have spent another 3 hours debugging this!

So I opened up GetInfoHandler.php and sure enough there is no function called “uploadprogress_get_info()”. It seems you guys forgot to put that function in, or maybe I am supossed to write one?

So I resolved the issue by simply using the “php_simple” handler.

May I suggest that you guys change the documentation for Vault…

  • For a start you need to say that when you deffine the “setServerHandlers” parameters you need to include the path and you to tell us what it is relative to.

  • Mention somewhere the differences between the handlers.

TomHartill Thanks a lot for this information about “php_simple” handler instead of “php”.
I had exactly the same problem since 2 days and your solution saved me.

And I agree with you for your 2 suggestions about documentation because I was looking for long time.

And to complete your response, I would add that the “setServerHandlers” parameter is relative to his own folder (php_simple).

uploadprogress_get_info() is part of the PECL package in PHP 5.2+ but unfortunately not all hosts are equal. They do not always uppate this package.

Would be nice if the dhtmlxVault were set up to check that this function was really installed rather than hoping it is.

I notified my host to install the package, but if I have problems, I guarantee you my clients will.