S.No
|
Web Service
|
API
|
1
|
Interaction between two machines over a network. | Interaction between two API. |
2
|
Uses SOAP, REST, and XML-RPC as a means of communication. | It may use any way to communication |
3
|
Web Services involves calling of system. | We can render form in one line, one by one element, element OR decorator OR error separately. |
4
|
Web service might not contain a complete set of specifications and sometimes might not be able to perform all the tasks that may be possible from a complete API. | An API consists of a complete set of rules and specifications for a software program to follow in order to facilitate interaction. |
5
|
All Web services are APIs | All APIs are not Web services |
6
|
A Web service always needs a network for its operation | API doesn't need a network for its operation |
7
|
WebServices are services available over internet. You can call these services and get so information in your application without know how it works. For example weather webservices gives you information about the city weather. | API is a collection of class which provide you some functionality like Google api gives google-search. |
We are Web Technology Experts Team who provide you Important information on Web Development, Interview Questions and Answers, live project problem and their solution and online free tutorials.
Tuesday, 20 May 2014
Difference between WebService and API
Monday, 19 May 2014
PHP Check Mime Type of File - Return Information About A File
Now a days, we are uploading files like Profile images, Video files OR excel files in our web application.
With uploading these files there are chances some user upload the .exe file (Virus) by renaming the .exe into .jpg, which can damage website.
You might have added the extension check from javaScript as well as PHP. But this is not enough from security end because someone can upload the file after changing the extension of file( ".exe" to ".png"). In this case your security check will be failed.
What to do.
Answer is check the Mime of file before get uploaded in your web server.
How to do this
"fileinfo" is extension which must be enabled in your php.ini. (for existence you can check in phpinfo)
If this extension is not enabled ask your server admin, he will do this for you OR you can also do this your self (http://php.net/manual/en/fileinfo.installation.php).
After installing the fileinfo extension, use following code to get the mime type of file before get uploaded in web server.
if (function_exists("finfo_file")) { $finfo = finfo_open(FILEINFO_MIME_TYPE); //file which you want to check the mime of the file $file = $_SERVER['DOCUMENT_ROOT'] . '/images/feedback.png'; //file which is going to get uploaded in web server try { $type = finfo_file($finfo,$file); echo "File Type: ".$type; } catch (Exception $e) { echo $e->getMessage(); } } else { echo "'finfo_file' is Not installed"; }
When you execute above code, if will get the mime-type of file. This is directly checking the mime type of already uploaded file.
You can use $type = finfo_file($finfo,$file); for checking the file type, before using move_uploaded_file function.
Best Related Posts are Following:
- Top 10 PHP Interview Questions and Answers.
- PHP Questions and Answers for experienced.
- PHP Difficult Interview Questions and Answers.
- How to Detect Request type (GET OR Post ) in PHP.
- PHP Basic questions and answers for fresher and experienced.
- PHP Mysql Interview Questions and Answers for fresher and experienced.
- PHP interview questions and answers for 5 year experienced.
- PHP Frequently asked Questions and Answer 2015.
- PHP problem solving interview questions and answers for Fresher and Experienced.
- PHP Interview Questions and Answers for 2 year Experience.
- What is stdClass? and How to create stdClass class?.
- Advanced PHP Interview Questions and Answers.
- SPDY Protocol - Improve the Speed of web page.
- PHP Technical Interview Questions and Answers for Fresher and Experienced.
- How to stop parsing the HTML tags?.
- Difference between Notice and warning and fatal error.
- Object Oriented Programming in PHP.
- Htaccess RewriteRule Flags by Code Example.
- Enabling the openssl in Wamp-Xampp.
- How to find day of week in php in a specific timezone.
- Zend Cache Tutorial - Zend Framework 1.12.
- Important PHP Interview Questions and Answers - jQuery, SQL Modes, Client Programs and Reset.
- PHP Check Mime Type of File - Return Information About A File.
- PHP Captcha Code Example Code Snippets.
- PHP - Secure Ajax Call from Hackers - Example.
- Zend Database Query - Zend Profiler Example - Code Snippets.
- Export to CSV File - PHP.
- htaccess code snippets example.
- OOP Interview Questions and Answers.
- CURL Example.
- PHP Interview Questions and Answers PDF.
- Stored Procedure - Advantage of Stored Procedure - Disadvantage of Stored Procedure.
- How To Track the Real IP Address Behind the Proxy - PHP - REMOTE_ADDR.
- Pending Interview Questions and Answers.
- Cache in PHP - Speed Up your website.
- PHP DataStructures.
- php interview questions and answers for 1 year experience.
- PHP Interview Questions and Answers for Experienced.
- Difference between Abstract class and Interface in PHP.
- Concurrent Connections of Apache Server.
- Regular Expressions PHP/Javascript.
- php interview questions and answers.
- What is Zend Engine in PHP.
Subscribe to:
Posts
(
Atom
)