Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar Refresh Video 79 #139

Closed
Dragotic opened this issue Jul 7, 2015 · 6 comments
Closed

Avatar Refresh Video 79 #139

Dragotic opened this issue Jul 7, 2015 · 6 comments

Comments

@Dragotic
Copy link

Dragotic commented Jul 7, 2015

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
Copy link
Contributor

creptor commented Jul 7, 2015

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
Copy link
Author

Dragotic commented Jul 8, 2015

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
Copy link
Contributor

creptor commented Jul 9, 2015

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. 😄

@JasonMate
Copy link

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: 😄]


Reply to this email directly or view it on GitHub
#139 (comment)
.

@Dragotic
Copy link
Author

Dragotic commented Jul 9, 2015

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

really stupid of me :/ Anyway, thank you guys 👍

@Dragotic Dragotic closed this as completed Jul 9, 2015
@JasonMate
Copy link

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: 👍]


Reply to this email directly or view it on GitHub
#139 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants