开发者

how to read uploaded files from xampp

开发者 https://www.devze.com 2022-12-29 17:46 出处:网络
I have this code for uploading files on the server: <tr> <td> <form 开发者_JAVA技巧enctype=\"multipart/form-data\" action=\"uploadaction.php\" method=\"POST\">

I have this code for uploading files on the server:

<tr>
<td>
<form 开发者_JAVA技巧enctype="multipart/form-data" action="uploadaction.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
</td>
</tr>
<tr>
<td>
Select the image: <input name="uploadedfile" type="file" />

</td>
<tr>
<td>
<input type="submit" value="Upload File" />
</form>
</td>
</tr>

And here's the action form:

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

What php function will I use? Can you give me an example on how to read the file back and display it in the browser? Please help, thanks.


PHP's documentation about file uploads should solve your problem. If it does not and you still have a question about it, feel free to come back and ask again.

0

精彩评论

暂无评论...
验证码 换一张
取 消