•How to upload files using PHP?

Answers were Sorted based on User's Feedback



•How to upload files using PHP?..

Answer / sei thu htun

Here is example code:
On HTML:
<form enctype="multipart/form-data" action="uploader.php"
method="POST">
<input name="uploadedfile" type="file" />
<input type="submit" value="Upload File" />
</form>

On PHP Script:

$target_path="YOUR_TARGET_PATH_FOR_STORE_UPLOAD_FILE_ON_SERVER";

if(@move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
$target_path)) {
echo "Success";
} else{
echo "Error";
}

Is This Answer Correct ?    13 Yes 1 No

•How to upload files using PHP?..

Answer / kapil dhiman

<?php

move_uploaded_file($_FILES['file']['tmp_name'],"images/".$_FILES['file']['name']);

?>
<form action="" method="post" enctype="multipart/form-data">
File<input type="file" name="file" /><input type="submit" name="sub" value="Upload" />
</form>

Is This Answer Correct ?    4 Yes 0 No

•How to upload files using PHP?..

Answer / rashmi

On HTML:
<form enctype="multipart/form-data" action="uploader.php"
method="POST">
<input name="uploadedfile" type="file" />
<input type="submit" value="Upload File" />
</form>
On PHP script:
<?php
$data="any_file.Ext";
$ft=filetype($data);
header('content-type: application/$ft');
header('content-length:'filesize($data));
header('content-disposition:filename='.$data);
echo file_get_contents($data);

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More PHP Interview Questions

What beforeFilter() is used?

0 Answers   HCL,


In mail($param1, $param2, $param3, $param4), the $param2 contains__

1 Answers  


What is the difference between the functions UNLINK and UNSET?

8 Answers   Silicon Biztech,


What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?

3 Answers  


Can we use include ("xyz.php") two times in a php page "index.php"?

0 Answers  


How to download and install php on windows?

0 Answers  


What is curl php?

0 Answers  


Is php a framework?

0 Answers  


can anyone tel me about the Expression engine Note:Its a CMS in Php

2 Answers  


What is the use of mvc in php?

0 Answers  


how to store case sensitive data in mysql ? how repair mysql table? diff bet float, double,real? diff bet mysql_fetch_object() and mysql_fetch_array()? which version of mysql support procedure , trigger? diff php4 and php 5? op - 2+5+"8"=? how to create object in javascript? query - select games from team who won games 2/4/6? NaN command in php? How to offload System date in mysql? typecasting in php? how to convert string to two decimal no? how to parse xml file in php command line argument in php? diff bet $msg,$$msg? diff bet require(), include(), include_once()? tables in mysql?

2 Answers   Aloha Technology,


How will you create a bi-lingual site (multiple languages) ?

3 Answers  


Categories