Hi,
The documents are not uploaded in a particular directory. I send variables through the place where you will upload.
And there is no example in the documentation that shows this.
The component is limited or is it possible?
It is very easy to do. Server script has a variable with upload target. Set it to whatever you need.
The question that can not silence: How?
The script I use is the usual in .Net:
vault.setFilesLimit (1);
vault.create (vaultDiv ");
</ Script>
Where does this variable?
Man, as I told, it’s on server! Look into “UploadHandler.ashx”
private const string UploadFolder = @"c:\upload\";
Fedor, thanks for the prompt service.
I’ve seen this code in the file.
But how to redeem this parameter using the “UPLOAD”?
Perhaps expressed myself bad. I use ASP to interface with server side. Net.
<%
filelocation var = request.querystring ("upfileon)
'This is my variable and this is the asp script
%>
<script>
dhtmlXVaultObject vault = new ();
vault.setImagePath ("codebase / imgs /");
vault.setServerHandlers (UploadHandler.ashx "
"GetInfoHandler.ashx"
"GetIdHandler.ashx");
vault.setFilesLimit (1);
vault.create (vaultDiv ");
</ Script>
Would you show me?
Sorry, this is wrong. This page is not ASP script, it is simply a html view. If you want to change the location, please go to the server side script. I do not understand what you are trying to do?
No problem Fedor, try follow me.
My code:
<html>
<head>
<title>Upload Control</title>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxvault.css" />
<script language="JavaScript" type="text/javascript" src="codebase/dhtmlxvault.js"></script>
<script language="JavaScript" type="text/javascript">
var vault = null;
function doOnLoad() {
vault = new dhtmlXVaultObject();
vault.setImagePath("codebase/imgs/");
vault.setServerHandlers("UploadHandler.ashx", "GetInfoHandler.ashx", "GetIdHandler.ashx");
vault.create("vault");
}
</script>
</head>
<body onLoad="doOnLoad()">
path:<input type="text" value="" size="25"><br>
<div id="vault"></div>
</body>
</html>
My screen:
I want upload the file teste.txt to directory showed no input text and not in @"c:\upload";
With this, I can always choose where to save the file.
could understand me?
Yes. Here is the sample.
- html code for the new field:
<p>Path: <input id="save_path_txt" value="c:\upload\"><input type="button" value="Set path" onclick="vault.setFormField('save_path',document.getElementById('save_path_txt').value)"></p>
- server code in “UploadHandler.ashx”:
finally
{
fp.Dispose();
fp.CloseStreams();
CurrentSize = "-1";
}
try {
string original_file = UploadFolder + fp.CurrentFileName;
string destination_file = context.Request.Params["save_path"] + fp.CurrentFileName;
File.Move(original_file, destination_file);
}
catch (Exception ex)
{
// process this error
}
sample-target.zip (2.68 KB)
Tks a lot but don´t work.
Original code:
http://ww1.dlbca.com.br/vaultx/index.html
save file with aaa+filename.ext
Your code:
http://ww1.dlbca.com.br/vaultx/Upload%20Target.html
save file with filename.ext
Destination File:
http://ww1.dlbca.com.br/vaultx/files/
There is a missing { in server handler - after the word “try”
Linha 123: try {
Linha 124: string original_file = UploadFolder + fp.CurrentFileName;
Linha 125: string destination_file = context.Request.Params["save_path"] + fp.CurrentFileName;
Linha 126: File.Move(original_file, destination_file);
Linha 127: }
Almost there Fedor.
Now is working but it just saves the file in the original directory.
It doesn’t move to the directory indicated in the text field.
Original Destination File:
http://ww1.dlbca.com.br/vaultx/files/
Directory indicated in the text field:
http://ww1.dlbca.com.br/vaultx/files2/
Man, do you have some debugger experience at all? Or do you think I have no other things to do? Give me your link again.
Sorry man, i don´t have that experience.
I just need a litle help with this.
I promess, i don´t longer upset you with that
Original Virtual directory.
http://ww1.dlbca.com.br/vaultx/files/
Fisical path:
E:\Sistemas\UploadVault\dhtmlx\dhtmlxvault_pro 1.6\handlers\aspx\files\
Indicated Virtual directory.
http://ww1.dlbca.com.br/vaultx/files2/
Indicated Fisical path:
E:\Sistemas\UploadVault\dhtmlx\dhtmlxvault_pro 1.6\handlers\aspx\files2\
Original code:
http://ww1.dlbca.com.br/vaultx/index.html
save file with aaa+filename.ext
Your code:
http://ww1.dlbca.com.br/vaultx/Upload%20Target.html
save file with filename.ext
It says it cannot find the vault variable from the event handler
onClick="vault.setFormField
Try to move your script code up to the page header.
<script language="JavaScript" type="text/javascript">
var vault = null;
vault = new dhtmlXVaultObject();
vault.setImagePath("codebase/imgs/");
vault.setServerHandlers("UploadHandler_move.ashx", "GetInfoHandler.ashx", "GetIdHandler.ashx");
vault.create("vault1");
</script>
and do the code like we said in the document load handler.
<html>
<head>
<title>Upload Control</title>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxvault.css" />
<script language="JavaScript" type="text/javascript" src="codebase/dhtmlxvault.js"></script>
<script language="JavaScript" type="text/javascript">
var vault = null;
function init_vault() {
vault = new dhtmlXVaultObject();
vault.setImagePath("codebase/imgs/");
vault.setServerHandlers("UploadHandler_move.ashx", "GetInfoHandler.ashx", "GetIdHandler.ashx");
vault.create("vault1");
}
</script>
<style>
body{font-family:arial;font-size:12px}
h1 {cursor:pointer;font-size:16px;margin-left:10px;line-height:10px}
xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
.hdr{
background-color:lightgrey;
margin-bottom:10px;
padding-left:10px;
}
</style>
</head>
<body onload="init_vault()">
<div id="vault1">
</div>
<p>Path: <input id="save_path_txt" name="save_path_txt" value="E:\Sistemas\UploadVault\dhtmlx\dhtmlxvault_pro 1.6\handlers\aspx\files2\"> <input type="button" value="Set path" onClick="vault.setFormField('save_path',document.getElementById('save_path_txt').value);alert(document.getElementById('save_path_txt').value)"></p>
</body>
</html>
Check if the folder2 is writable by aspnet user, also add some logging for the exception in the file.move code part.
Fedor,
Not working but now i know how to do.
I’ll check with my network administrator permissions of the folders in IIS.
Tks a million.
Hi to all.
I’ve the same problem using JSP Handler and doesn’t work.
I want to change dinamically the upload folder using:
vault.setFormField(“upload_folder”, document.getElementById(‘contextCurrentDir’).value);
where contextCurrentDir is my txt field.
I’m debugging UploadHandler.jsp and the problem is getting the POST variable upload_folder
String uploadFolder = request.getParameter(“upload_folder”);
The variable uploadFolder is always null,
then the POST parameter is not passed to UploadHandler.jsp.
Can someone help me ?
Thanks in advance
Saverio
Hi, you should do it in a different way. As long as we have our own request processor, you should use the following code:
if (item.isFormField()) {
//processFormField
String fieldName = item.getFieldName();
String value = item.getString();
// do your work here
} else {
Thanks very much.
Now i understand and it works
Hi Fedor, i was looking for something like this
<p>Path: <input id="save_path_txt" value="c:\upload\"><input type="button" value="Set path" onclick="vault.setFormField('save_path',document.getElementById('save_path_txt').value)"></p>
but if my form have 20 fields then i need to press the “Set path (or something)” button for attach the value in every one
I think we need a event called onBeforeUpload to call a handler and make this more flexible
Sorry for my bad english