PDA

View Full Version : Zipping large HTML Uploads


bcmiller189
09-05-2006, 01:48 PM
Ok, I have a question. I run an online baseball league using a simulation program. This is what I use my site for. The game creates a lot of HTML, thousands of small pages actually that are a real pain to upload individually. Now, I know other people who will zip their files, uplad it to the proper folder and it then unzip it into the proper place once it is uploaded. I don't know if we have that capability. If so, how would I do this? It would save me an amazing amount of upload time.

Matt
09-05-2006, 07:34 PM
How do you want to approach this? Are you looking for a completely automated solution, i.e. you upload the created files at xx:yy every day or I mean rather what do you have available?

Personally I'd use rsync (http://samba.anu.edu.au/rsync/) to synchronize the files over daily and skip any manual interventions to get the files from your computer to the server.

I assume you'd like to access a script on your Web site that scans a directory for zip files and unzips each one to somewhere on the server, right? That's simply a mixture of glob (http://php.net/glob) and Zip (http://us2.php.net/zip) in PHP.

If you want to make a shell script that you can access from the browser....


#!/bin/bash
echo -e "Content-type: text/html\n\n"
for file in /var/www/html/uploads/*.zip ; do
unzip $file -d /var/www/html/placeforfiles/
echo "Extracted $file"
done


Make sure you save that with Unix-style end-of-line markers (\n) and chmod to 755. Done and done.

bcmiller189
09-05-2006, 08:09 PM
How do you want to approach this? Are you looking for a completely automated solution, i.e. you upload the created files at xx:yy every day or I mean rather what do you have available?

Personally I'd use rsync (http://samba.anu.edu.au/rsync/) to synchronize the files over daily and skip any manual interventions to get the files from your computer to the server.

I assume you'd like to access a script on your Web site that scans a directory for zip files and unzips each one to somewhere on the server, right? That's simply a mixture of glob (http://php.net/glob) and Zip (http://us2.php.net/zip) in PHP.

If you want to make a shell script that you can access from the browser....


#!/bin/bash
echo -e "Content-type: text/html\n\n"
for file in /var/www/html/uploads/*.zip ; do
unzip $file -d /var/www/html/placeforfiles/
echo "Extracted $file"
done


Make sure you save that with Unix-style end-of-line markers (\n) and chmod to 755. Done and done.


Thanks man, you're the best

bcmiller189
09-06-2006, 06:17 PM
Ok, Matt, I actually am going to need further help. I created a little PHP using ht code you showed and uploaded it here (http://www.atlanticcoastbaseball.com/unzip.php). I really lack the skill to do anything automated and since 3 times week I have to manually generate the HTML files it isn't abig issue to then upload the zip and manually go there to have it unzip. Problem is I still can't get it working, instead it is just basically displaying the text of the code. Truth is we are well past any basic knowledge I have so I am not sure how to get this working, can you see what i am doing wrong?

Matt
09-07-2006, 03:28 PM
That's a shell script. Rename it to unzip.cgi and you should be fine. I went ahead and took care of that for you, so you should be set.

bcmiller189
09-07-2006, 07:53 PM
That's a shell script. Rename it to unzip.cgi and you should be fine. I went ahead and took care of that for you, so you should be set.

As always you are the best man, thank you.

bcmiller189
11-02-2006, 10:17 PM
I'm not sure what is going on here, as you saw earlier when I posted about the 403 error here (http://forums.apisnetworks.com/showthread.php?p=595#post595) now this script isn't working. Don't know why exactly. I simply reuploaded what was already working. For some reason I seem to be having issues. I have tried correcting the permissions like you indicated in the other thread as well and have had no successs.

Matt
11-03-2006, 03:39 AM
It looks like you went through a massive chmod'ing spree. chmod unzip.cgi back to 755 and that'll fix it.

bcmiller189
11-03-2006, 12:05 PM
I have actually tried that. Everytime I try browsing to it now though it gives me this error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, bmiller@cavtel.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.0.54 (Unix) Server at www.atlanticcoastbaseball.com Port 80

Matt
11-03-2006, 02:12 PM
unzip.cgi worked fine for me when I accessed it just now. :confused: