Linux Blog

Dealing with the HTML file input limitation of uploading multiple files

Filed under: General Linux — TheLinuxBlog.com at 8:59 am on Thursday, August 28, 2008

Everybody knows how annoying the <input type=”file”> HTML tag is right? Does it make you mad when you have to browse and upload each file individually? Sure you can use JavaScript to add / remove the input boxes, but you still need to browse for each file individually, which if you’re uploading lots of files doesn’t make sense.

Would you like a multiple file uploader like Facebook has? Perhaps more of a simple explorer like interface that will allow you to select multiple files? Possibly previewing them, and perhaps processing them on the client side?

Well, I wouldn’t say it was the easiest thing in the world to implement but there is an open source multiple file uploader that might suit your needs. Since its written in Java, its highly expandable (if you know how or pay a development company or freelancer) and can also be partially configured with JavaScript.

What is this fantastic sounding multiple file uploader you speak of?

Its called jupload and can be downloaded from jupload.sourceforge.net. Don’t let the website fool you because this tool is actually pretty neat.

If any one would like examples on how to use it, just write a blog post linking to me saying how cool it is and how much you need it, offer me cash, comment or participate in this blog, offer me goods / services, give me links from your website or just e-mail me politely asking for help and I’ll see what I can do.

If you don’t like it: start reading the documentation like I did, seriously its not that hard.

Recursive MD5 Sum Script

Filed under: Shell Script Sundays — TheLinuxBlog.com at 12:08 am on Sunday, December 9, 2007

This week I made this shell script to search one level deep and MD5 all of the files. I did this because I had multiple images and I wanted to see what images were the same so that I could merge them together. Its a pretty simple script & the output is the same as md5suming a file except there is more than one sum generated.

#MD5 Files in the directories
md5Dir () {
echo $directory;
for x in $(ls -1 $directory); do
md5sum $directory’/'$x;
done;
}
#Lists The Directories
for i in $(ls | grep active); do
directory=$i;
md5Dir;
done;

It only does one level deep but thats good enough for now. I am going to make it search recursively depending on the levels given by the user. I would also like to make it display files that are the same at the end.

It gets the job done for small directories, but if I wanted to run it on large multiple directories with lots of files in them I would definitely redirect the output to a file because it can be quite overwhelming. To run it just copy the code into a file and do the following:

sh <filename>

I hope this helps some one who is trying to MD5 multiple files in different directories!

Introduction to CHMOD – Octal Format

Filed under: General Linux,Quick Linux Tutorials — TheLinuxBlog.com at 1:25 pm on Tuesday, September 25, 2007

CHMOD is used to change permissions on a file. There are three types of permissions read, write, execute and there are three types that permissions can be set for owner, group and other.
It can be used with a symbolic representation or with an octal number that represents the bits. This blog post features on just the octal format. CHMOD works on most Linux file systems. It is also used on other operating systems such as BSD. Web designers and developers may be familiar with CHMOD as they have to set permissions when uploading files via FTP.

The octal notation can seem quite confusing but is actually very simple.
To figure out the octal format take the following table:

  Owner Group Other
Read 4 4 4
Write 2 2 2
Execute 1 1 1

To figure out the octal method just add up the sum of what you want to set the permissions to.
If you would like to set the permissions for the owner to read, write execute and the group/other to read and execute you would do the following:

  Owner Group Other
Read 4 4 4
Write 2 2 2
Execute 1 1 1
Add: 7 5 5

Its that simple. The way I remember the numbers to the corresponding permission is to remember that the number starts with 4 and is divided by two and then I repeat the following:
“For Read, Two Write, Execute”
meaning that 4 is read, 2 is write and the last (1) is execute.

There are graphical utilities that set permissions such as Thunar in XFCE and Konqeuror for KDE, but they normally do not allow you to change the permissions on multiple files at once.

If you have a whole directory full of files that you would like to change permissions on, you can simply do:

chmod 755 *

* is a wild card or regex and tells chmod to change permissions on all files.

If you would like chmod to go into directories and change permissions on files, the -R option is used.

chmod 755 -R *

will change permissions on all files and dive into the folders also.

chmod is an absolute must for system administrators and is good to know for home Linux users. If your experimenting with chmod be careful and do not use the -R option unless your absolutly sure you need to. I have accidentally used chmod to recursivly change permissions on a whole drive before. Lets leave it at this was not what I call a fun time since I had changed them to a very open 777.

Take that as your warning.