Upload update_photo File

parent 8b9f6a17
<?php
include('session.php');
$fileInfo = PATHINFO($_FILES["image"]["name"]);
if (empty($_FILES["image"]["name"])){
$location=$srow['photo'];
?>
<script>
window.alert('Uploaded photo is empty!');
window.history.back();
</script>
<?php
}
else{
if ($fileInfo['extension'] == "jpg" OR $fileInfo['extension'] == "png") {
$newFilename = $fileInfo['filename'] . "_" . time() . "." . $fileInfo['extension'];
move_uploaded_file($_FILES["image"]["tmp_name"], "../upload/" . $newFilename);
$location = "upload/" . $newFilename;
mysqli_query($conn,"update `user` set photo='$location' where userid='".$_SESSION['id']."'");
?>
<script>
window.alert('Photo updated successfully!');
window.history.back();
</script>
<?php
}
else{
?>
<script>
window.alert('Photo not updated. Please upload JPG or PNG files only!');
window.history.back();
</script>
<?php
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment