Check size of file before upload!

Is it really possible to check the size of a file before uploading it? For the past few weeks, I've been doing quite a lot of R & D towards this. Finally, I came to a conclusion that it is possible with a Java Applet. With a Java Applet you can check the size of a file and do virtually any other manipulations to it without uploading it to the server. When done this way, it saves a lot of bandwidth on the user who is going to use your application. Here are couple of links that might help you in getting this done in a quicker way;

1) JFile Upload : Supports HTTP and FTP based upload. They also claim to compress the files before doing the real upload. The official website is here.

2) JUpload: If you are looking for a open source based solution, then this is the right one. Contains all the necessary features that are required to implement a file upload solution. The open source link is available here.

Installing ImageMagick on Windows -- Setup Imagick on PHP

I had a tough time yesterday trying to install ImageMagick on Windows. I got the correct binary file, but when I tried to invoke it with the PHP extension (php_imagick.dll) it was not getting loaded at all!!. Searching all over the web did not help..Finally I managed to fix the problem and felt I should give a clear procedure that will help anybody to install ImageMagick on Windows XP with proper DLL file for PHP. Here is what I did and if you do the same, you should get this working without any problems..

ImageMagick References

Step 1 : Do not download the latest version of ImageMagick. Rather download this version : ImageMagick-6.4.1-0-Q8-windows-dll. You can get this version from the following link . You get all the versions here. Make sure you pick the right one. If you miss here, you are gone!

Step 2: After downloading it, install the binary. Do not install it to c:\program files..etc..rather install it to a location like c:\imagemagick. (assuming c: as your root directory).

Step 3: After installation, run the 'convert' command from DOS mode. It should work. If it does not, check the PATH environment variable and make sure that 'c:\imagemagick' is added correctly there.

Step 4: We need to add one more environment variable MAGICK_HOME. (New one). The value of this variable should hold the directory path where imagemagick is installed. (c:\imagemagick in this case)

Step 5: I need to set this up on Apache 2.2x with PHP 5.2.6. In the Apache httpd.conf file, add this line to the end of the file. "SetEnv MAGICK_HOME “C:/imagemagick” (without quotes and watch the '/'..Make sure that you refer to the correct path here).

Step 6: Download the correct extension file for PHP. If you are using the same version that I have listed, then you can get the extension from here. If this link is broken, let me know.

Step 7: PHP.ini file needs to be updated. Identify the extension directory for PHP correctly and place the DLL file inside the directory. Update the PHP.ini file with this extension.

Step 8: Restart Apache once all this is done.

Step 9: After restart, make sure that the imagick extension got loaded correctly with phpinfo(). If you have done all the above steps correctly, and the extension dll has not got loaded, then you have picked up an invalid dll file. Check the file.

Step 10: Execute a sample code like this (add php header tag)


thumbnailImage(100, 0);
echo $image;
?>

It should work and you are done!!

If you get an error like this

PHP Fatal error: Class 'Imagick' not found in....

Then, the extension file is not loaded properly. Check the extension file.

Any queries, comment in the blog. I shall help to resolve it.. Also, check out the following books..They are highly useful