File upload issue [part 2]

I have already discussed about the file upload issue in this post. In this blog post I will give some code for uploading the files into the server.
Easy way to check the file extension in php:

<?php 
$ext = end(explode(".",strtolower($_FILES['theupload']['name']))); 
?>

In this line of code I get the extension of any uploaded file in our script. after getting the extension you can check whether it is an image or a video. In this portion I will check whether it is an image or not by a normal conditional statement.

<?php 
if($ext=="jpg" || $ext=="jpeg" || $ext=="gif" || $ext=="png") {
//do stuff
}else{
 //give user an error msg.
}
?>

Problem while uploading long tail video?
It is a problem while uploading long tail video on the server even when you want to upload a video file more than 16 MB without configuring your php.ini file, you will have problems :(, problems that can make you crazy over your php script. Frankly I was that much crazy with my php script. I knew that I do not have problems in my script but while uploading long tail video the whole screen become blank :(. There is one thing you can do in this situation. You can search into google about uploading long tail video and another important thing is checking your php.ini file for the uploading configuration. Here I am listing the settings in php.ini what we need to modify.

file_uploads
upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size

Read the documentation there in the file and after changing the settings you need to restart your xampp. You are ready to upload now according to your limit settings 🙂

Advertisements

About Mazharul Anwar

A PHP and javascript nerd believe in web applications and open source goodness. Ex MS Windows user converted to linux fanboy and love gadgets. Coding in python and maintaining servers become my passion. Website performance and optimization geek.
This entry was posted in Programming and tagged , , , , , . Bookmark the permalink.

One Response to File upload issue [part 2]

  1. social media says:

    Great post. I used to be checking constantly this blog and I’m impressed!
    Very helpful information particularly the closing part 🙂 I
    maintain such information much. I was seeking this particular info for a long time.
    Thank you and best of luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s