•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 is good average session duration?
how to overcome server time behind twleve hours compare to local system time
What is the main difference between asp net and php?
How do you define a constant in php?
How to return a value back to the function caller?
1. Write a function to swap two values ? $a = 10; $b = 20; echo $a, $b; swap(); // If u want u can pass parameters echo $a, $b; // It should print 20 , 10
14 Answers Aquasol, Infosys, TCS, Torque Infotech,
Which function would you use to format date information in php?
What are the advantages of stored procedures in php?
How can you increase the maximum execution time of a script in php?
What is the meaning of a final class and a final method?
Where is session value stored php?
Explain how does one prevent the following warning ‘warning: cannot modify header information – headers already sent' and why does it occur in the first place?