-1
私のサーバーに画像をアップロードし、画像名をデータベースに保存しようとしています。しかし、私が自分のフォームに記入すると、リフレッシュされ、何もしません。誰かがそれがフォルダに保存されない理由を知っていますか?イメージがPHPのフォルダに保存されていません
<?php
if(isset($_POST['btn_save_updates'])) {
$id = $_GET['id'];
$email = $_POST['email'];
$signature = $_POST['signature'];
//if they DID upload a file...
if($_FILES['avatar']['name'])
{
//if no errors...
if(!$_FILES['avatar']['error'])
{
//now is the time to modify the future file name and validate the file
$new_file_name = strtolower($_FILES['avatar']['tmp_name']); //rename file
if($_FILES['avatar']['size'] > (2048000)) //can't be larger than 1 MB
{
$valid_file = false;
$error = 'Oops! Your file\'s size is to large.';
}
//if the file has passed the test
if($valid_file)
{
//move it to where we want it to be
move_uploaded_file($_FILES['avatar']['tmp_name'], 'avatar/'.$new_file_name);
$filename = $_FILES['avatar']['name'];
// run update statement here ...
$error = 'Settings have been updated.';
}
}
//if there is an error...
else
{
//set that to be the returned message
$error = 'Oops! Error: '.$_FILES['avatar']['error'];
}
}
}
?>
HTMLフォーム::
<form method="post" role="form" autocomplete="off">
<div class="form-group">
<label for="email">Email</label>
<input type="text" name="email" id="email" tabindex="1" class="form-control" value="<?php userProfile("email"); ?>" autocomplete="off">
</div>
<div class="form-group">
<label for="signature">Signature <i id="sign_tooltip" class="fa fa-exclamation-circle" aria-hidden="true" ata-toggle="tooltip" data-placement="right" title="You can add images to your signature!"></i></label>
<script>
$("#sign_tooltip").hover(function(){
$('#sign_tooltip').tooltip('show')
});
</script>
<textarea rows="4" name="signature" id="signature" tabindex="3" class="form-control" autocomplete="off"><?php userProfile("signature"); ?></textarea>
</div>
<br /><br />
<div class="form-group">
<label for="email">Avatar</label><br /><br />
<img src="avatars/<?php userInfo('avatar'); ?>" alt="Default Avatar" class="img-circle" width="140" height="140"><br /><br />
<input name="avatar" id="avatar" tabindex="4" class="input-group" type="file" accept="image/*" />
</div>
<div class="form-group">
<div class="row">
<div class="col-xs-7">
</div>
<div class="col-xs-5 pull-right">
<button type="submit" name="btn_save_updates" id="btn_save_updates" tabindex="5" class="form-control btn btn-success"><i class="fa fa-floppy-o" aria-hidden="true"></i> Save </button>
</div>
</div>
</div>
</form>
@jesseこの作品はありましたか? –