I would like to upload a file (say a tarball or a text file) to my server. I can select it fine on the client, how do I get it to the server?
Thanks,
Rachel
I would like to upload a file (say a tarball or a text file) to my server. I can select it fine on the client, how do I get it to the server?
Thanks,
Rachel
Where do you want to place it on the server…in a record or on the file system ?
On the file system.
Servoy doesn’t give you that functionality by default. You would have to write a plugin that can access the server (-filesystem) using RMI.
or…if you really want it…i could introduce a new aspect to my data-stream plugin api which would allow you to do it
sorry for the plug, but it seems like an obvious way out
anyone else be interested in this ?
J
I already do this in my Tools plugin, but only the privately available part
I can make it a commercial project from now and make it available to everybody.
That would also give me the opportunity to introduce the new ‘barcode’ part which outputs an image of an EAN128, code128, code39 etc. barcode…
Marcel, do you stream the payload or do you send an object via RMI ?
For small files it may not be significant, but for larger files (of which tarballs are likely candidates), you may prefer to stream the payload.
J
Untill today I send the object to the server, didn’t see any reason (yet) to do it otherwise but streaming is an option for the future ofcourse
Minerva, how would you like to specify the disk location ?
Relative or absolute path ?
One issue might be the write privilege, but if you specify only disk locations to which a write is assured, then you should be safe.
What action should be taken if a file of the specified name already exists ?
If you are interested in having this function added to my data-stream plugin please just let me know and I will introduce it.
You can peek at my website to get an understanding of usage and pricing:
http://www.cybersack.com/servoy/R1.0/Pr … ducts.html
Also, you can download a demo version of the software.
See:
http://forum.servoy.com/viewtopic.php?t=4598
Julian
I would definitely be interested in it. However, I fear that I need it sooner than you would be able to implement it. I will try to do the blob approach.
Thanks,
Rachel
Why don’t you use the ftp plugin or the hhtp plugin to upload the file via a server http form? I use the latter with apache+php.
That sounds like an excellent solution. Would you mind giving me a snippet of your code illustrating how you do it?
Thanks,
Rachel
Here you are:
<?php
$uploadDir = '/usr/apache2/htdocs/your_upload_dir/';
$uploadFile = $uploadDir.$_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
{
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
}
else
{
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
echo $uploadFile;
}
print "</pre>";
?>
This is the equivalent of this HTML form:
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="userfile" type="file" />
<input type="submit" value="Upload File" />
</form>
// Some vars
var upload_url = 'http://www.your_site.com/upload.php'
var file_name = 'your_file_name.ext'
var file_path = 'path_to_your_file'
//Check if the file esists
var localFile = plugins.file.getFileSize(file_path)
if (localFile)
{
//Set status area to give some feedback to the user
application.setStatusText('Uploading...')
application.updateUI()
//HTTP post execution
var poster = plugins.http.getPoster(upload_url)
var didAddFile = poster.addFile('userfile',file_name,file_path)
var httpCode = poster.doPost() //(httpCode 200 is ok)
if ( httpCode == '200' )
{
plugins.dialogs.showInfoDialog( 'Web Upload', 'Upload successful.', 'Ok')
}
else
{
plugins.dialogs.showErrorDialog( 'Web Upload', 'Upload Error: '+httpCode, 'Doh!')
}
//Reset the StatusBar
application.setStatusText('')
}
else
{
plugins.dialogs.showErrorDialog( 'Error!', 'The selected file doesn\'t exist.', 'Doh!')
}
Check the method carefully, I use this in a slighlty different context but it should give you the idea of what has to be done.
Hope this helps!
what is the download link for the ftp bean/plugin ?
Nobody knows it, I asked the Servoy team a while ago but nobody seems to recall where to find it.
makes it a bit difficult to use
I have just sent a copy to Johan Compagner. I suppose he can organize a download possibility…
patrick:
I have just sent a copy to Johan Compagner. I suppose he can organize a download possibility…
I hope so, http post is standard in Servoy but ftp support would be really nice too.
good work patrick
Johan posted the bean here:
http://downloads.servoy.com/downloads/bean_plugin/ftpbean.jar