I am trying to upload a file via a form and a php file. I have used the same method many times throughout my website with no problems, however this time I just can not get it to work. On my form I have this....
<span class="purple"><strong>Upload Your Image</strong></span>
<input name="userfile" type="file" id="userfile" class="textbox">
<br /><br />
<label>
<input name="submit" type="submit" class="createbutton" id="submit1" value="ADD TO BASKET">
</label>
In my php file I have this...
//upload image first
$uploaddir = '../images/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
$status = 1;//uploaded
$data["printfile"] = $_FILES['userfile']['name'];
} else {
$status = 0;//cant upload
echo "Upload Failed!\n";
$err = "";
}
Every time it just gives me the Upload Failed error message. Any ideas?
Ah right, I really feel like a fool now. I somehow managed to miss enctype="multipart/form-data" on my form tag. Thanks so much for your help, works perfectly now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.