For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2006 > Upload multiple files using PHP and VBScript or JavaScript









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Upload multiple files using PHP and VBScript or JavaScript
Susan

2006-01-23, 7:55 am

Is it possible to use PHP with VBScript or JavaScript to upload multiple
files.
I'd like to automate the upload of a complete directory (not using FTP).
I don't need a common form with several upload boxes.

Thanks in advance,

Susan


Erwin Moller

2006-01-23, 7:55 am

Susan wrote:

> Is it possible to use PHP with VBScript or JavaScript to upload multiple
> files.
> I'd like to automate the upload of a complete directory (not using FTP).
> I don't need a common form with several upload boxes.


So what is it that you DO need?

What you are describing here is extremely vague.

Please post a coherent question with enough information for others to help
you.

In general: Javascript has nothing to do with file-uploads. JS cannot touch
anything of interest concerning the local filesystem.
You need the local filesystem to select files you want to upload.

Futher: Both PHP and VBscript can handle forms that contain files, but in
PHP it is all much more easy to code.

Regards,
Erwin Moller

>
> Thanks in advance,
>
> Susan


Susan

2006-01-23, 7:55 am

I want to upload all files from specific directory to my server without
adding them one by one to a form.
So i need some code (VBScript perhaps, because php can't do that) to add
these file to my upload page.
I already did some research with the multifile form examples, but thats to
much work, because there are a lot of files :-)

So i need an upload page (php), browse for the intended directory, push the
submit button ....and voila. (But i don't think it's that simple)

Susan


Al

2006-01-23, 6:56 pm

Erwin Moller wrote:
> So what is it that you DO need?


I think she wanted to be able to select a directory (or maybe one file
in a directory with a FILE input) and then have javascript/vbscipt work
out the rest of the files that need uploading before the user clicks
submit and maybe stick them in hidden FILE inputs or something equally
cunning.

And I'm not sure you CAN do it, but I suppose you can always try. Maybe
if you do it the second way I mentioned you can hook javascript up to
the onchange event (if one exists) of the FILE input and then browse
the local directory (if that's possible) and then create some new file
inputs (visiblity=hidden/display=none) and actually inject their
'value' params from the list you got. Then the user can click submit
and all the files will be submitted.

But that had a lot of ifs...

Peace

2006-01-23, 9:55 pm

PHP work on server-side
VBScript or JavaScript cant access your file on HD

you might need other language to list all file in directory and send it
to your PHP program
:)

Susan

2006-01-24, 6:56 pm

> PHP work on server-side
> VBScript or JavaScript cant access your file on HD
> you might need other language to list all file in directory and send it
> to your PHP program


VBScript CAN access files on HD. (take a look at
"Scripting.FileSystemObject", it's very powerful)
But how to use this to send it to my php site.

Susan


alexrussell101@gmail.com

2006-01-24, 9:55 pm

Susan wrote:
> VBScript CAN access files on HD. (take a look at
> "Scripting.FileSystemObject", it's very powerful)
> But how to use this to send it to my php site.


Well I can't be bothered to actually make anything work but here's what
i'd do (and yes I'm pretty much repeating my earlier post):

Have a file input with a name of something like "file[0]". Hope there's
some kind of onchange event that you can run some code from.
This code should do the following: checking the directory of the file
input and get its contents to an array (did you want to recurse subdirs
or not? well here's where you go about doing it).
Step through this array and create some more inputs (using
document.forms["formname"].innerHTML =+ <input....>" or something
similar that'll actually work, I haven't tested this but you can work
the details out for yourself) named "file[1]", "file[2]", etc. as
needed giving them a 'style="display: none"' attribute and a
'value="full_path_to_file"' attribute (I'm assumign this is actually
possible. Again, you can test...)

Now when the user clicks submit, hopefully you'll get all the files
uploaded into an array file[]. Although bearing in mind how PHP handles
file uploads maybe the array idea isn't the best, again do some tests.

The problem occurs if the users changes their mind about the upload
directory. You'll have to erase all of those created inputs and make
new ones, although I'm pretty sure that's not too hard.


I might look into some code for this later on if no-one else has any
ideas in the meantime. Hope this helps!

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com