•How to upload files using PHP?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What beforeFilter() is used?
In mail($param1, $param2, $param3, $param4), the $param2 contains__
What is the difference between the functions UNLINK and UNSET?
What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?
Can we use include ("xyz.php") two times in a php page "index.php"?
How to download and install php on windows?
What is curl php?
Is php a framework?
can anyone tel me about the Expression engine Note:Its a CMS in Php
What is the use of mvc in php?
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?
How will you create a bi-lingual site (multiple languages) ?