•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 |
Is php a float?
What is print_r?
What is the use of 'print' in php?
Can we extend multiple classes in php?
Which is better mysql or sql?
How can we know the total number of elements of Array?
Does php need apache?
How is session data stored?
What is mod_php?
What is sql injection in php?
How to get tabels from database in php andd display it in the table form using codelgniter? plz help me
What are the Advantages and Application Areas of PHP?