Jump to content

unlink help


digitalgod

Recommended Posts

hey guys,

I made this script where an admin can approve/decline user submitted pics but I ran into a snag.

here's part of the script

[code]
function delete($user_dat, $globalvars)
    {
        $split_imgname = explode('.', $_GET['delete']);
        
        if($split_imgname[1] == null)
        {
            echo "We shall have no directory deleting here.";
            
            $exitp = new template();
            $exitp->exitp($user_dat, $globalvars);
        }
        
        if(unlink($_GET['user'] . "/" . $_GET['delete']))
        {
            @unlink($_GET['user'] . "/thumbnails/" . $split_imgname[0] . ".gif");
            mysql_query("DELETE FROM vibe_img WHERE username = '" . $_GET['user'] . "' && image_name = '" . $_GET['delete'] . "'");
            
        } else {
            echo "Could not remove the image because of unknown errors. ";
            echo 'Click <a href="' . $_SERVER['PHP_SELF'] . '?admin=viewuploads">here</a> to go back.';
        }
    }
    
    function viewuploads($user_dat, $globalvars)
    {
        $sql = 'SELECT * FROM vibe_img WHERE status = "Pending Approval" ORDER BY img_date';
        $query = mysql_query($sql) or die('SQL Error <br>'.$sql.'<br>'.mysql_error());
    
        while($data = mysql_fetch_assoc($query))
        {
            $rem_array = array("-", ".", "!", " ");
            $js_functions = str_replace($rem_array, "", $data['image_name']);            
            $split_name = explode('.', $data['image_name']);
            
            echo '<script>
                                
                function del' . $js_functions. '()
                {
                    var delimgfinal = confirm("Are you sure you want to delete, ' . $data['image_name'] . '?")
                    if(delimgfinal == true)
                    {
                        window.location = "' . $_SERVER['PHP_SELF'] . '?admin=delete&delete=' . $data['image_name'] . '&user=' . $data['username'] . '"
                    } else {
                    
                    }
                }
                </script>';
            
            echo '<a href="users/' . $data['username'] . '/' . $data['image_name'] . '" target="_blank"><img src="users/' . $data['username'] . '/thumbnails/' . $split_name[0] . '.gif" border="0" /></a><br /><p></p>';
            echo '<input type="button" onclick="app' . $js_functions . '()" value="Approve" />
                <input type="button" onclick="del' . $js_functions . '()" value="Decline" /><br /><p></p>';
        }
        
    }
[/code]

my problem is that it always gives me an error saying that the image file doesn't exist even though it does and it's looking in the right directory

here's the error I got

Warning: unlink(admin/Fish.jpg): No such file or directory

and it does that to whatever user I try to delete the pic except it says the member's username instead of admin

any ideas?
Link to comment
https://forums.phpfreaks.com/topic/9070-unlink-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.