thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Avatar Refresh Video 79 #139

Closed Dragotic closed 9 years ago

Dragotic commented 9 years ago

Hello guys,

lets go right into it! My avatar doesn;t refresh when a new one is uploaded. Here is the code:

From users.php

<?php if(isset($opened['id'])) { ?>
    <script type="text/javascript">

        $(document).ready(function{

            Dropzone.autoDiscover = false;

            var myDropzone = new Dropzone("#avatar-dropzone");

            myDropzone.on("complete", function(file) {

                $("#avatar").load("ajax/avatar.php?id=<?php echo $opened['id']; ?>");

            });
        });

    </script>
<?php } ?>

From avatar.php

<?php 

include('../../config/connection.php');

$id = $_GET['id'];

$q = "SELECT avatar FROM users WHERE id = $id";
$r = mysqli_query($dbc, $q);

$data = mysqli_fetch_assoc($r);

?>

<img src="../uploads/<?php echo $data['avatar']; ?>">
creptor commented 9 years ago

For best results with load place the sentence just after the end of the php, like this -> ?><img src="../uploads/<?php echo $data['avatar']; ?>">

Then you have to make sure the path to the image is right. (for the script you give, the image is at [root of file showing the image]/uploads/image)

Finally search inside of your database that the images names are stored with there extensions... like .jpg , .png , etc.

Dragotic commented 9 years ago

Unfortunately the first option didn't work. As for the other one, both the path and the extensions are correct. I just said that it doesn't refresh the avatar by itself, if i do refresh the page by myself the new picture is loaded.

creptor commented 9 years ago

You can try looking at the code first, and then compare it to when you upload a image, to look for errors or mistakes. If you don't know or be sure of this just post it here. :smile:

JasonMate commented 9 years ago

You could try on "success like this.

    $(document).ready(function{

        Dropzone.autoDiscover = false;

        var myDropzone = new Dropzone("#avatar-dropzone");

        myDropzone.on("success", function(file) {

            $("#avatar").load("ajax/avatar.php?id=<?php echo

$opened['id']; ?>");

        });
    });

On Wed, Jul 8, 2015 at 8:35 PM, creptor notifications@github.com wrote:

You can try looking at the code first, and then compare it to when you upload a image, to look for errors or mistakes. If you don't know or be sure of this just post it here. [image: :smile:]

— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/139#issuecomment-119792403 .

Dragotic commented 9 years ago

I'm so stupid...if you look at the first function inside from users.php i forgot to put () after the function!

really stupid of me :/ Anyway, thank you guys :+1:

JasonMate commented 9 years ago

Ha nice catch! :P

On Thu, Jul 9, 2015 at 5:13 AM, Dragotic notifications@github.com wrote:

I'm so stupid...if you look at the first function inside from users.php i forgot to put () after the function!

really stupid of me :/ Anyway, thank you guys [image: :+1:]

— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/139#issuecomment-119914891 .