digitalgod Posted May 4, 2006 Share Posted May 4, 2006 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 directoryhere's the error I gotWarning: 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 adminany ideas? Quote Link to comment https://forums.phpfreaks.com/topic/9070-unlink-help/ Share on other sites More sharing options...
digitalgod Posted May 4, 2006 Author Share Posted May 4, 2006 nevermind found my own mistake, it was actually pointing at the root directory instead of where my script was Quote Link to comment https://forums.phpfreaks.com/topic/9070-unlink-help/#findComment-33366 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.