# using file plugin

**URL:** <https://forum.servoy.com/t/using-file-plugin/13393>\
**Category:** Classic Servoy\
**Created:** [January 3, 2011, 3:12pm UTC](https://forum.servoy.com/t/using-file-plugin/13393 "2011-01-03T15:12:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mo\_ca\_mo](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@mo\_ca\_mo](https://forum.servoy.com/u/mo_ca_mo)\
**Post date:** [January 3, 2011, 3:12pm UTC](https://forum.servoy.com/t/using-file-plugin/13393/1 "2011-01-03T15:12:49Z")

</div>

Hello,  
I have to do a simple task: to save an image which i obtain from a scan using a pluguin.  
I got the image but i couldnt save it  
i use the code as follows but i couldnt solve my problem:

var srcArray = plugins.scannerPro.GetTwainSources()  
var scanObject = plugins.scannerPro.QuickScan(‘license\_key’,srcArray[0],‘jpg’);

var image = plugins.images.getImage(scanObject);  
var tempFile = plugins.file.createFile(‘fotoreceta’,‘.jpg’)  
plugins.file.writeFile(tempFile, image)  
var ok = plugins.file.copyFile(tempFile,‘O:\Recetas’)

‘O:\Recetas’ is the path where i want to save the image.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [January 3, 2011, 7:02pm UTC](https://forum.servoy.com/t/using-file-plugin/13393/2 "2011-01-03T19:02:19Z")

</div>

why are you using a temp file and then copy it?  
why not directly create the output file you want?

edit also use the forward slash: / instead of backward \ in file paths.

---

<div class="post-metadata">

**Author:** ![mo\_ca\_mo](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@mo\_ca\_mo](https://forum.servoy.com/u/mo_ca_mo)\
**Post date:** [January 4, 2011, 12:02pm UTC](https://forum.servoy.com/t/using-file-plugin/13393/3 "2011-01-04T12:02:23Z")

</div>

Problem solved:

var f = plugins.file.createFile(nombre)  
if (!plugins.file.writeFile(f, scanObject))  
application.output(‘Failed to write the file.’)  
var path = ‘o:/Recetas/’ + nombre  
var ok = plugins.file.copyFile(f,path)

thank you

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [January 4, 2011, 3:27pm UTC](https://forum.servoy.com/t/using-file-plugin/13393/4 "2011-01-04T15:27:24Z")

</div>

you’re still writing it twice…

---

<div class="post-metadata">

**Author:** ![mo\_ca\_mo](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@mo\_ca\_mo](https://forum.servoy.com/u/mo_ca_mo)\
**Post date:** [January 4, 2011, 4:31pm UTC](https://forum.servoy.com/t/using-file-plugin/13393/5 "2011-01-04T16:31:02Z")

</div>

Thank you again.

var scanObject = plugins.scannerPro.QuickScan(‘license\_key’,srcArray[0],‘jpg’);  
var f = plugins.file.createFile(path);  
if (!plugins.file.writeFile(f, scanObject))  
application.output(‘Failed to write the file.’);
