• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

how can i save my images through javascript into my selected directory?

sir i have code this---

<body>
<img src="images/www.bikao.com/2.gif" />
<script language="javascript">
javascript:Ai7Mg6P='';
      for (i7M1bQz=0;i7M1bQz<document.images.length;i7M1bQz++){
                  Ai7Mg6P+='<img src='+document.images[i7M1bQz].src+'><br>';
                  images = document.images[i7M1bQz].src;//mine
            };
            if(Ai7Mg6P!=''){
                  //document.write('<center>'+Ai7Mg6P+'</center>');
            alert(images);//save all images here in 'images directory'
                  void(document.close());
            }else{
                  alert('No images!');
            }
</script>

</body>

i want to save all images in images directory where i am doing alert how can it would be done plz plz help me today is the dead line of the project just i have to save them all.

thanks in advance.
0
naeembhatti
Asked:
naeembhatti
  • 3
  • 2
1 Solution
 
Ivo StoykovCommented:
Hello naeembhatti,

Unless it is a .hta application I doubt that browser will allow this... Anyway here is a small sample(s)
[JScript]
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile ("c:\\mydocuments\\letters\\*.doc", "c:\\tempfolder\\")
[VBScript]
FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"


HTH

I
0
 
naeembhattiAuthor Commented:
sir i have modify my code like this

fso = new ActiveXObject("Scripting.FileSystemObject");
javascript:Ai7Mg6P='';
      for (i7M1bQz=0;i7M1bQz<document.images.length;i7M1bQz++){
                  Ai7Mg6P+='<img src='+document.images[i7M1bQz].src+'><br>';
                  images = document.images[i7M1bQz].src;//mine
            };
            if(Ai7Mg6P!=''){
            
                  //document.write('<center>'+Ai7Mg6P+'</center>');                  
                  //alert(Ai7Mg6P+'-'+images);                  
                  fso.CopyFile (images, 'images/'+images);
            //alert(images);

                  void(document.close());
            }else{
                  alert('No images!');
            }

i know it would not run on every browser but i when i run it on firefox it does not copy my image and if i run on ie(but not my requirement for ie) it gives my error "automation server can't create object"

??

0
 
Ivo StoykovCommented:
Hi naeembhatti,

this is because running the script on IE there is permission deny for creating file system object - this is a security issue and you cannot bypass it.

but you could rename your file to *.hta and then file system object will be accepted - this is a high risk action though...

regards

I
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
naeembhattiAuthor Commented:
okey right i got it but e.g
if i have a singel file named as images.html
and code is simple this
<script type="text/javascript">
   
var fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFile("E:\AppServ_5\www\pligg\test\9.gif", "E:\AppServ_5\www\pligg\test\images/9.gif");

</script>

why this code is not running this is not .hta ?
or what could be other methods or example to copy file through javascript plz plz help me.
0
 
KennyTMCommented:
Hi.

How about

<HTML>
<HEAD>
  <TITLE>HTA Demo</TITLE>
    <HTA:APPLICATION ID="oHTA"
     APPLICATIONNAME="myApp"
     BORDER="thin"
     BORDERSTYLE="normal"
     CAPTION="yes"
     ICON=""
     MAXIMIZEBUTTON="yes"
     MINIMIZEBUTTON="yes"
     SHOWINTASKBAR="no"
     SINGLEINSTANCE="no"
     SYSMENU="yes"
     VERSION="1.0"
     WINDOWSTATE="maximize"/>
  <SCRIPT>
function window.onload () {
  var fso = new ActiveXObject("Scripting.FileSystemObject");
  fso.CopyFile("E:\\AppServ_5\\www\\pligg\\test\\9.gif", "E:\\AppServ_5\\www\\pligg\\test\\images\\9.gif");
}
</SCRIPT>
</HEAD>
<BODY><P>File copied.</P></BODY>
</HTML>

? The script is partly refered to http://msdn.microsoft.com/workshop/author/hta/reference/objects/hta.asp . Also look out for backslashes in Javascript: it's an escape character, and to say a normal "\" you'll need two: "\\".

I haven't tested the above script.
0
 
naeembhattiAuthor Commented:
hmm no it is not copying the image.
ok let me think some other alternates for it.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now