I am trying to use a basic upload form to place an image onto my server, and would like the code to post the new image url on the page after the upload. I am aware this is a vague question, but I have done a good amount of searching with no usable results. If anyone could help me with this or just give a point in the right direction it would be much appreciated.
<form action="upload.php" method="post" enctype="multipart/form-data">
<p>
<label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br />
<button>Upload File</button>
<p>
</form>
is all that I have so far I know it is not much to start with I do not know how to handle the data that is sent to ‘upload.php’
Look Here. Similar to how you use the
$_POSTarray, you can use the$_FILESarray to retrieve files that were submitted by a form.The
$_FILESarray will contain$_FILES["file"]["tmp_name"]after upload, where “file” is the input name in the form. There are PHP frameworks that help you work better with the temporary files though.How to use? In the php file containing the form:
And then in upload_file.php:
Is this what you were asking for ?