Uploading Multiple files
Moderator: General Moderators
Uploading Multiple files
Before I put pen to paper and start scratching my head, I am sure some one else has had the same problem.
I wish to create an online gallery for a client. The upload will resize the photo, add a watermark, create a thumbnail and upload into a specific new folder. As well as check the max size and file type.
This is ok if I was going to upload a single image or just a few but its likely to be a hundred or so. The stuff I have seen so far suggests a file element/input tag for each image, which is not practical. What I want to do is select a bunch of files (shift-click) or all the files in a particular directory and then test each as they are uploaded in a batch i.e. like a drag and drop but with all the checking and resizing ect.
Anyone now how to do this or can direct me in the right direction?? Many thanks.
I wish to create an online gallery for a client. The upload will resize the photo, add a watermark, create a thumbnail and upload into a specific new folder. As well as check the max size and file type.
This is ok if I was going to upload a single image or just a few but its likely to be a hundred or so. The stuff I have seen so far suggests a file element/input tag for each image, which is not practical. What I want to do is select a bunch of files (shift-click) or all the files in a particular directory and then test each as they are uploaded in a batch i.e. like a drag and drop but with all the checking and resizing ect.
Anyone now how to do this or can direct me in the right direction?? Many thanks.
I'd try http://sourceforge.net/index.php
The search term file upload returns some seemingly feasible results.
The search term file upload returns some seemingly feasible results.
Thanks Vodka will give it a go.
One way I was thinking was to examine the files in a 'default' upload directory on the local computer into an array then use that array to cycle through and create the inputs to $_Files and then foreach through the $_Files array to upload the listed files. Will post back if successful.
One way I was thinking was to examine the files in a 'default' upload directory on the local computer into an array then use that array to cycle through and create the inputs to $_Files and then foreach through the $_Files array to upload the listed files. Will post back if successful.
php runs on the server, not the client. You cannot use php to
the java applet on the other side does run on the client.examine the files in a 'default' upload directory on the local computer into an array then use that array to cycle through and create the inputs to $_Files and then foreach through the $_Files array to upload the listed files
cheers for the comment...hmmmm...easy to confuse things when working locally.....I guess the use of JavaScript is called for to read the local directory, create a list of directory content and then import that as a guide for a php batch upload.
Can you get php to read Javascript arrays/cookies?
I had a quick look at sorceforge...a few codes promised multiple uploads but they still have a selection of file inputs, rather than a shift-clikc selection of a quantity of files. Found quite a few other people having a similar problem so it looks like I am not the only one!
Can you get php to read Javascript arrays/cookies?
I had a quick look at sorceforge...a few codes promised multiple uploads but they still have a selection of file inputs, rather than a shift-clikc selection of a quantity of files. Found quite a few other people having a similar problem so it looks like I am not the only one!
I've tried JUpload. Select a directory and it adds all files in that directory to the upload list.
And then it's still the client (or something that runs on the client) that uploads the actual data. Not php, which runs on the server and cannot access the data and therefore must wait for a client side app to upload it.
e.g. if I have a html form likeand upload three files fileA.txt, fileB.txt and fileC.txt each containing only the text Text of File(ABC) the browser sends the following http requestIt sends that literally, character by character. It doesn't care or know that maybe php will handle that request. And on the other hand/side php doesn't care "why" the browser sends this requests. It doesn't know about a html form with three input/file elements and yadda yada. It gets the request data and parses it accordingly.
You need something on the client-side that sends such a http request for all files in a directory. I believe JUpload can be that something.
JavaScript cannot access the local file system. You need e.g. a java applet.beinn wrote:I guess the use of JavaScript is called for to read the local directory, create a list of directory content and then import that as a guide for a php batch upload
And then it's still the client (or something that runs on the client) that uploads the actual data. Not php, which runs on the server and cannot access the data and therefore must wait for a client side app to upload it.
e.g. if I have a html form like
Code: Select all
<form enctype="multipart/form-data" action="http://localhost:8000/script.php" method="POST">
<div>
<input name="userfile[0]" type="file" /><br />
<input name="userfile[1]" type="file" /><br />
<input name="userfile[2]" type="file" /><br />
<input type="submit" value="Send File" />
</div>
</form>Code: Select all
POST /script.php HTTP/1.1
Host: localhost:8000
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.8,de-de;q=0.5,de;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------174171315717575
Content-Length: 537
-----------------------------174171315717575
Content-Disposition: form-data; name="userfile[0]"; filename="fileA.txt"
Content-Type: text/plain
Text of FileA
-----------------------------174171315717575
Content-Disposition: form-data; name="userfile[1]"; filename="fileB.txt"
Content-Type: text/plain
Text of FileB
-----------------------------174171315717575
Content-Disposition: form-data; name="userfile[2]"; filename="fileC.txt"
Content-Type: text/plain
Text of FileC
-----------------------------174171315717575--You need something on the client-side that sends such a http request for all files in a directory. I believe JUpload can be that something.
I have looked through my JavaScript books and yup don'ty seem to be able to do it...arrgghh I am having the problem of knowing you can read and write files ect but only to local directories which would be on the server an dnot the remote machine (i..e user's machine).
I have seen JUpload mentioned but the link I found failed, I have just googled it and it looks very similar to something else I am trying called csxPostUpload.
The main problem is to capture the upload i.e. in $_Files array and make the changes I want to before uploading to the server.
Thanks for the tip will let you know the outcome.
I have seen JUpload mentioned but the link I found failed, I have just googled it and it looks very similar to something else I am trying called csxPostUpload.
The main problem is to capture the upload i.e. in $_Files array and make the changes I want to before uploading to the server.
Thanks for the tip will let you know the outcome.
The second link points to JUpload (File Upload Applet).volka wrote:I'd try http://sourceforge.net/index.php
The search term file upload returns some seemingly feasible results.
found a solution
Nothing more fustrating the finding a forum but no solution, so here is mine.
Overview: Need to code the admin area of a photographer so that he could upload photos for his clients to view online.
Problem: The photographer will need to upload hundreds at a time. So selecting each photo via an input tag is not acceptable. But this is the only method offered by php-
http://www.php.net/manual/en/features.f ... ltiple.php
Solution: You need a client side solution that will allow shift-click selection of files in a browse window.
Flash will offer this via 'FileReferenceList'. One solution is
http://www.codeproject.com/aspnet/Flash ... sg=2188857
Alternatively you can use a Java applet such as Jupload.
http://www.jupload.biz/
There are other solutions, just google them. Both of these worked fine when I tested them locally. But failed completely when I tested them on a live site. The reason was that both Flash and Java caused a HTTP Status code error 406 (sometimes 403). The reason for this error was an installed 'firewall' called mod_security. This module examines POST submissions and if they are not formatted correctly then it rejects them.
One solution is to disable mod_security via htaccess or if you know, disable the bit that causes the failure.
http://help.textdrive.com/index.php?pg=kb.page&id=85
However, if the hosting provider is security minded then they will not allow you to do this and you will get a 500 error.
So if you hosting on windows or your host does not use mod_security etc you are ok. But if not....
This is where I was left. The solution I found was to use ActiveX (Linux hosting with PHP, MySQL and ActiveX hmmm!!). There are a number of ActiveX components out there. Some are more difficult to use than others but none seem to be free for commercial use.
http://www.download.com/3000-2421_4-10624849.html
The thing to remember is that activeX is working client side. So a cab file on your hosting (e.g. Linux) is downloaded for the client to use, you may face some hassle getting a licence sorted for some of the ActiveX solution, but CuteUpload licenses based on the domain you initially provide.
After accepting the ActiveX component and it then downloads the activeX for use on their machine, a one time operation. One drawback is that is will only work using Windows/IE which is ok for most people. The ActiveX stores the files selected and uploads them one at a time to the file handling script (e.g. file.php) server side.
Hope that helps someone.
Overview: Need to code the admin area of a photographer so that he could upload photos for his clients to view online.
Problem: The photographer will need to upload hundreds at a time. So selecting each photo via an input tag is not acceptable. But this is the only method offered by php-
http://www.php.net/manual/en/features.f ... ltiple.php
Solution: You need a client side solution that will allow shift-click selection of files in a browse window.
Flash will offer this via 'FileReferenceList'. One solution is
http://www.codeproject.com/aspnet/Flash ... sg=2188857
Alternatively you can use a Java applet such as Jupload.
http://www.jupload.biz/
There are other solutions, just google them. Both of these worked fine when I tested them locally. But failed completely when I tested them on a live site. The reason was that both Flash and Java caused a HTTP Status code error 406 (sometimes 403). The reason for this error was an installed 'firewall' called mod_security. This module examines POST submissions and if they are not formatted correctly then it rejects them.
One solution is to disable mod_security via htaccess or if you know, disable the bit that causes the failure.
http://help.textdrive.com/index.php?pg=kb.page&id=85
However, if the hosting provider is security minded then they will not allow you to do this and you will get a 500 error.
So if you hosting on windows or your host does not use mod_security etc you are ok. But if not....
This is where I was left. The solution I found was to use ActiveX (Linux hosting with PHP, MySQL and ActiveX hmmm!!). There are a number of ActiveX components out there. Some are more difficult to use than others but none seem to be free for commercial use.
http://www.download.com/3000-2421_4-10624849.html
The thing to remember is that activeX is working client side. So a cab file on your hosting (e.g. Linux) is downloaded for the client to use, you may face some hassle getting a licence sorted for some of the ActiveX solution, but CuteUpload licenses based on the domain you initially provide.
After accepting the ActiveX component and it then downloads the activeX for use on their machine, a one time operation. One drawback is that is will only work using Windows/IE which is ok for most people. The ActiveX stores the files selected and uploads them one at a time to the file handling script (e.g. file.php) server side.
Hope that helps someone.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
activeX? ewe...
Facebook uses a java applet as a progressive enhancement to a bunch of inputs, which I'm assuming are uploaded via an ajax call...
If you use XULrunner (or FF extension) or something similar you can read the local filesystem, but that's more of an application than a web page admin section.
I'd even take flash over activeX.
Facebook uses a java applet as a progressive enhancement to a bunch of inputs, which I'm assuming are uploaded via an ajax call...
If you use XULrunner (or FF extension) or something similar you can read the local filesystem, but that's more of an application than a web page admin section.
I'd even take flash over activeX.
-
Steve Mellor
- Forum Commoner
- Posts: 49
- Joined: Thu Aug 02, 2007 8:18 am
The problem that beinn had, of course, was that Flash was being blocked by the server. Now I found another solution called SWFUploader (http://swfupload.mammon.se/) which is what I like to think of as FLAPJAX (Flash, Javascript, PHP in a kind of an Ajax environment).
There version 6.2 is now running with the new flash player and actionscript 3 and I have heard roumers that they have solved the specific problem I was having. Not sure how the server side problem beinn was experiencing would be fixed though.
I happen to like the pure Flash solution but if you can't get it working it's about as useless as AOL.
There version 6.2 is now running with the new flash player and actionscript 3 and I have heard roumers that they have solved the specific problem I was having. Not sure how the server side problem beinn was experiencing would be fixed though.
I happen to like the pure Flash solution but if you can't get it working it's about as useless as AOL.