Posted By:
7 Mar, 2014 11:57 pm PST

How to upload file in PHP application?

 

1)               How to upload file in PHP application?

 

Very often, you come across situation where you are filling online form where you have to upload some file like your image , digital signature , or CV ect… this uploaded files are stored on the server.

PHP provides this feature through $­_FILE[] superglobal array.

 

move_uploaded_file() this method moves an uploaded file from temporary location to new location

Syntax:-

move_uploaded_file(String $tempfilename , String $destination)

 

$tempfilename:- is temporary file name which is can be obtained from superglobal variable $_FILES[filename]['tmp_name'].

 

$destination:- is target directory where you want to store .

 

//Write PHP application that will accept resume file(text file) and image of that person through web form and display information about Uploaded file.

 

       
   

<html >

 

<head >

 

<title ></ title >

 

<meta http - equiv =" Content - Type " content =" text / html ; charset =UTF -8" -

 

> 

 

</head >

 

<body >

 

<form action =" UploadedFileHandling .php " method =" POST " enctype =" -

 

multipart /form - data ">

Select Text file<input type =" file " name =" resume " value ="" /><br >

 

Select Image file<input type =" file " name =" photo " value ="" />

 

<input type =" submit " value =" submit " />

 

</form > </body >

 

</html >

 

UploadForm.html

 
 
 

<?php

 

echo "<h2 ><pre >";

 

var_dump ( $_FILES );// shows information about uploaded file

 

echo '<pre >';

 

move_uploaded_file ( $_FILES ['resume '][ 'tmp_name ']," upload /{ $_FILES -

 

[' resume '][' name ']}");// move file from temporary location totarget location

 

echo " Stored in: upload / { $_FILES [' resume '][' name ']}";

 

move_uploaded_file ( $_FILES ['photo '][ 'tmp_name ']," upload /{ $_FILES -

 

[' photo '][' name ']}");// move file from temporary location totarget location

 

echo "<pre > stored in upload /{ $_FILES [' photo '][' name ']}";

 

 

?>

UploadedFileFandlinh.php

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

UploadPage

 

UploadResult

 

 

 




Please login to reply to this problem.



Related Problems on Fixoncloud