Topic :PHP File
Faculty Name:Viji.VQ)What is the difference between using copy() and move() function in php file uploading?
Ans:) Copy() makes a copy of the file. It returns TRUE on success. It can copy from any source to destination. Move simple Moves the file to destination if the file is valid. While move can move the uploaded file from temp server location to any destination on the server. If filename is a valid upload file, but cannot be moved for some reason, no action will occur.
References
http://www.w3schools.com/PHP/php_file_upload.asp
http://php.net/manual/en/features.file-upload.php
Faculty Name:Viji.V
Q)What is the difference between the functions unlink and unset?
Answer:
unlink() deletes the given file from the file system.
unset() makes a variable undefined.
References
http://www.w3schools.com/PHP/php_file.asp
http://php.about.com/od/advancedphp/ss/php_read_file.htm
Faculty Name:Viji.V
Q)What is the maximum size of a file that can be uploaded using php and how can we
change this?
Answer:
You can change maximum size of a file set upload_max_filesize variable in php.ini
file.
References
http://php.about.com/od/advancedphp/ss/php_file_upload.htm
http://www.tizag.com/phpT/fileopen.php
Faculty Name:Saritha G Pillai
Q)How To Write the FORM Tag Correctly for Uploading Files?
Ans:)The uploading process is controlled by a properly written <FORM...> tag as:
<FORM ACTION=receiving.php METHOD=post ENCTYPE=multipart/form-data>
Note that you must specify METHOD as "post" and ENCTYPE as "multipart/form-data" in order for the uploading process to work. When users clicks the submit button, files specified in the <INPUT TYPE=FILE...> will be transferred from the browser to the Web server.
References
http://www.tizag.com/phpT/files.php
http://w3schools.com/php/php_file.asp
Faculty Name:Saritha G Pillai
Q)How to include external php file in to html page?
Ans:) 4 ways to do this:
include("filename.php");
require("filename.php");
include_once("filename.php");
require_once("filename.php");
References
http://php.about.com/od/advancedphp/ss/php_read_file_5.htm
http://www.tizag.com/phpT/files.php
Faculty Name:Saritha G Pillai
Q)How To Get the Uploaded File Information in the Receiving Script?
Ans:)Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] – The Original file name on the browser system.
$_FILES[$fieldName]['type'] – The file type determined by the browser.
$_FILES[$fieldName]['size'] – The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] – The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] – The error code associated with this file upload.
The $fieldName is the name used in the <INPUT TYPE=FILE, NAME=fieldName>
References
http://www.tizag.com/phpT/files.php
http://w3schools.com/php/php_file.asp
Faculty Name:Saritha G Pillai
Q)What’s the difference between include and require?
Ans:)It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
References
http://www.phpf1.com/tutorial/php-include-file.html
http://www.tizag.com/phpT/files.php
Faculty Name:Saritha G Pillai
Q)Use of chmod in php?
Ans:)chmod —for Changes file mode
Syntax: bool chmod ( string $filename , int $mode )
Attempts to change the mode of the specified file to that given in mode(octal value).
Eg:
// Read and write for owner, nothing for everybody else
chmod("/somedir/somefile", 0600);
// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);
// Everything for owner, read and execute for others
chmod("/somedir/somefile", 0755);
// Everything for owner, read and execute for owner's group
chmod("/somedir/somefile", 0750);
References
http://www.php.net/manual/en/function.chmod.php
http://w3schools.com/php/php_file.asp
No comments:
Post a Comment