Jump to: navigation, search

Php is uploaded file

From w3cyberlearnings

Contents

PHP function is_uploaded_file

This function checks whether a specific file has already uploaded. Please check PHP Image Upload and MySQL for the upload image using PHP and MySQL.

Syntax is_uploaded_file

filename is a file name to check.

is_uploaded_file(filename);

Return

Returns TRUE when it is successfully uploaded a file, else returns FALSE.

Example 1

Html form

<!DOCTYPE html>
<html>
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	<body>
		<form action="upload.php" 
				enctype="multipart/form-data" name="uploadform" method="post" >
			<input type="file" name="image123" id="image123"/>
			<input type="submit" name="upload"/>
		</form>
	</body>
</html>

upload.php

<?php

if (isset($_POST['upload'])) {
	$filename = $_FILES['image123']['tmp_name'];
	echo $filename;
	// upload file here
        // after upload check
	// print information about a file

	if (is_uploaded_file($filename)) {
		print_r($_FILES);
		
	}
}
?>

Output

  • upload to the temporary directory

C:\Windows\Temp\php9A5B.tmpArray
(
    [image123] => Array
        (
            [name] => Sophal_Resume_LAMP_04172011.doc
            [type] => application/msword
            [tmp_name] => C:\Windows\Temp\php9A5B.tmp
            [error] => 0
            [size] => 39424
        )

)

Related Links


basename-- chgrp-- chmod-- chown-- clearstatcache-- copy-- delete-- dirname-- disk_free_space-- disk_total_space-- diskfreespace-- fclose-- feof-- fflush-- fgetc-- fgetcsv-- fgets-- fgetss-- file_exists-- file_get_contents-- file_put_contents- file-- fileatime-- filectime-- filegroup-- fileinode-- filemtime-- fileowner-- fileperms-- filesize-- filetype-- flock-- fnmatch-- fopen-- fpassthru-- fputcsv-- fputs-- fread-- fscanf-- fseek-- fstat-- ftell-- ftruncate-- fwrite-- glob-- is_dir-- is_executable-- is_file-- is_link-- is_readable-- is_uploaded_file-- is_writable-- is_writeable-- lchgrp-- lchown-- link-- linkinfo-- lstat-- mkdir-- move_uploaded_file-- parse_ini_file-- parse_ini_string-- pathinfo-- pclose-- popen-- readfile-- readlink-- realpath_cache_get-- realpath_cache_size-- realpath-- rename-- rewind-- rmdir-- set_file_buffer-- stat-- symlink-- tempnam-- tmpfile-- touch-- umask-- unlink--

Navigation
Web
SQL
MISC
References