Last active
July 11, 2021 19:19
-
-
Save jimthoburn/5810636 to your computer and use it in GitHub Desktop.
A file upload example, with PHP. For Stack Overflow: http://stackoverflow.com/questions/15598963/why-does-my-form-not-upload-files-in-internet-explorer-9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Demo</title> | |
</head> | |
<body> | |
<?php | |
// KUDOS: http://www.php.net/manual/en/features.file-upload.post-method.php#example-354 | |
if (isset ($_FILES['file'])) { | |
echo '<pre>'; | |
$destination = 'data/' . basename($_FILES['file']['name']); | |
echo 'destination: ' . $destination . "\n"; | |
if (move_uploaded_file($_FILES['file']['tmp_name'], $destination)) { | |
echo "File is valid, and was successfully uploaded.\n"; | |
} else { | |
echo "Upload failed.\n"; | |
} | |
echo 'Here is some more debugging info:'; | |
print_r($_FILES); | |
print "</pre>"; | |
} | |
?> | |
<form action="." method="post" class="wpjb-form" enctype="multipart/form-data"> | |
<input type="hidden" name="resume_form" value="resume_form" /> | |
<fieldset class="wpjb-fieldset-default"> | |
<input id="firstname" name="firstname" type="hidden" class="regular-text " value="John" /> | |
<input id="lastname" name="lastname" type="hidden" class="regular-text " value="Henry" /> | |
<input id="email" name="email" type="hidden" class="regular-text " value="john.henry@johnhenry.com" /> | |
<div class="wpjb-element-input-checkbox wpjb-element-name-is_active"> | |
<label class="wpjb-label">Show resume? </label> | |
<div class="wpjb-field"> | |
<label for="is_active_1"><input type="checkbox" class="" name="is_active" id="is_active_1" value="1" checked="checked" /> Yes <small style="display:inline;">(Uncheck to hide your resume)</small></label> | |
</div> | |
</div> | |
<div class="wpjb-element-input-select-one wpjb-element-name-file"> | |
<label class="wpjb-label">Upload a <i>new</i> resume file</label> | |
<div class="wpjb-field"> | |
<input style="line-height:1em;" id="file" name="file" type="file" class="regular-text " /> | |
<small class="wpjb-hint">Accepted file types: doc, docx, odf, pdf, rtf</small> | |
</div> | |
</div> | |
</fieldset> | |
<p class="submit"> | |
<input type="submit" name="Submit" id="wpjb_submit" value="Save Changes" /> | |
</p> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment