# uploading file to the server

**URL:** <https://forum.servoy.com/t/uploading-file-to-the-server/4484>\
**Category:** Classic Servoy\
**Created:** [July 7, 2005, 1:27am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484 "2005-07-07T01:27:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.servoy.com/u/Minerva)\
**Post date:** [July 7, 2005, 1:27am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/1 "2005-07-07T01:27:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 7, 2005, 1:41am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/2 "2005-07-07T01:41:26Z")

</div>

Where do you want to place it on the server…in a record or on the file system ?

---

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.servoy.com/u/Minerva)\
**Post date:** [July 7, 2005, 5:29am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/3 "2005-07-07T05:29:53Z")

</div>

On the file system.

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [July 7, 2005, 8:49am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/4 "2005-07-07T08:49:28Z")

</div>

Servoy doesn’t give you that functionality by default. You would have to write a plugin that can access the server (-filesystem) using RMI.

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 7, 2005, 8:57am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/5 "2005-07-07T08:57:14Z")

</div>

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 ![:)]( "Smile")

sorry for the plug, but it seems like an obvious way out

anyone else be interested in this ?

J

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [July 7, 2005, 9:05am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/6 "2005-07-07T09:05:55Z")

</div>

I already do this in my Tools plugin, but only the privately available part ![:)]( "Smile")

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…

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 7, 2005, 9:16am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/7 "2005-07-07T09:16:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [July 7, 2005, 9:21am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/8 "2005-07-07T09:21:10Z")

</div>

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 ![:)]( "Smile")

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 7, 2005, 9:33am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/9 "2005-07-07T09:33:53Z")

</div>

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](http://www.cybersack.com/servoy/R1.0/PracticaServoyProducts.html)

Also, you can download a demo version of the software.  
See:  
[http://forum.servoy.com/viewtopic.php?t=4598](http://forum.servoy.com/viewtopic.php?t=4598)

Julian

---

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.servoy.com/u/Minerva)\
**Post date:** [July 7, 2005, 12:13pm UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/10 "2005-07-07T12:13:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [July 7, 2005, 2:29pm UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/11 "2005-07-07T14:29:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.servoy.com/u/Minerva)\
**Post date:** [July 7, 2005, 3:03pm UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/12 "2005-07-07T15:03:07Z")

</div>

That sounds like an excellent solution. Would you mind giving me a snippet of your code illustrating how you do it?

Thanks,  
Rachel

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [July 7, 2005, 3:35pm UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/13 "2005-07-07T15:35:19Z")

</div>

Here you are:

1. PHP script that receives the upload, save this as ‘upload.php’

```auto
<?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:

```auto
<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>

```

1. Servoy Method to start the Upload:

```auto
// 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!

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 7, 2005, 10:14pm UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/14 "2005-07-07T22:14:15Z")

</div>

what is the download link for the ftp bean/plugin ?

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [July 8, 2005, 8:52am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/15 "2005-07-08T08:52:49Z")

</div>

Nobody knows it, I asked the Servoy team a while ago but nobody seems to recall where to find it.

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 8, 2005, 8:56am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/16 "2005-07-08T08:56:17Z")

</div>

makes it a bit difficult to use ![;)]( "Wink")

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 8, 2005, 8:57am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/17 "2005-07-08T08:57:38Z")

</div>

I have just sent a copy to Johan Compagner. I suppose he can organize a download possibility…

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [July 8, 2005, 9:00am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/18 "2005-07-08T09:00:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cybersack](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@cybersack](https://forum.servoy.com/u/cybersack)\
**Post date:** [July 8, 2005, 9:12am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/19 "2005-07-08T09:12:45Z")

</div>

good work patrick ![:)]( "Smile")

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 8, 2005, 11:39am UTC](https://forum.servoy.com/t/uploading-file-to-the-server/4484/20 "2005-07-08T11:39:18Z")

</div>

Johan posted the bean here:

[http://downloads.servoy.com/downloads/bean\_plugin/ftpbean.jar](http://downloads.servoy.com/downloads/bean_plugin/ftpbean.jar)

[Next page](https://forum.servoy.com/t/uploading-file-to-the-server/4484.md?page=2)
