•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 die in php?
Do you know what is php?
What does $_cookie mean?
What is namespace in php?
Why do we use htaccess and where?
Write a program to find a string is palindrome or not?
How many php based companies in bangalore and chennai and over all india ? most of the persons saying for 2 years and 3 years they will be getting less than 15k per month how far is it true ? is it good scope for experience people can any one tell the exact experience pay for php developers one yr experience how much sal we expect ? two yr experience how much sal we expect ? three yr expereince how much sal we expect ? please kindly reply to the above questions as an experts you only please kindly judge and tell your practical experience in PHP ?
What is a helper function?
What exactly is PHP?
What are PHP Magic Methods/Functions. List them.
How will you calculate days between two dates in PHP?
When to use get and post request?