我在用户使用此注册表单上传图片时遇到问题:
<?php
errors = array();
$missing = array();
// check if the form has been submitted
if (isset($_POST{'submit'}) && !empty($_FILES)){
require_once('./classes/Ps2/Upload.php');
try {
$upload = new Ps2_Upload('my address');
$upload->move();
$messages = $upload->getMessages();
}catch (Exception $e) {
echo $e->getMessage();
}
$tmp_name = $_FILES['image']['tmp_name'];
$type = $_FILES['image']['type'];
$name = $_FILES['image']['name'];
$size = $_FILES['image']['size'];
$names = $_POST['names'];
$number = $_POST['number'];
$email = $_POST['email'];
$seminar = $_POST['seminar'];
$address = $_POST['address'];
$response = recaptcha_check_answer($private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if (!$response->is_valid) {
$errors['recaptcha'] = true;
}
<?
这是表单(至少是影响图像上传的部分):
<form id="register" name="register" method="post" enctype="multipart/form-data" action="">
<p>
<fieldset><legend class="caption">Registration Details</legend>
<p>
<label for="image">Upload image photograph:
<?php if ($missing && in_array('image', $missing)) { ?>
<span class="warning">Please pick your passport</span>
<?php } ?>
</label>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>">
<input name="image" id="image" type="file" value="image" tabindex="1">
</p>