Couple questions..
Moderator: General Moderators
your second is a result of the firstnick2 wrote:why won't this work?
code:errror:Code: Select all
<?php unlink("/" . $_COOKIE[user] . "/" . $_POST[delete]); header("location: Http://www.slices.net/pictures.php"); ?>
Warning: unlink(/mom/avatar1.jpg): No such file or directory in /home/virtual/site9/fst/var/www/html/removep.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at /home/virtual/site9/fst/var/www/html/removep.php:2) in /home/virtual/site9/fst/var/www/html/removep.php on line 3
the first means that it can't find the file. always use absolute paths. you probalby either don't realize you need to switch directories or don't switch properly.
there's a bunch of newbs lately that look like they are seekking someone to write or re-write a script for them.
try doing some debugging. instead of unlinking like you do, set it in a variable first, then echo that out. my guess is that you're not used to posix and don't realize / is the top level dir and you want to be in the user's dir wwhich would be /home/username/
Not because it matters much perhaps, but I'm adressing the first question just to make it noted:
Using unlink like that wont probably work as you are working on server structure rather than www-address structure.
...meaning, that if you unlink something, you must use /html/JAM/www/images/ as above shows.
Note that on windows it works differently, so if you are testing at home on a local server running on win32 you need to rearrange that.
Code: Select all
/*
loop dir, match 3 file ext's, if ok populate an array for later use.
using substr() to pick the last 4 chars in the supposed file (that might be
a directory), and use that to verify it...
*/
while (($file = readdir($dh)) !== false) {
if (substr($file,-4) == '.jpg' or substr($file,-4) == '.gif' or substr($file,-4) == '.bmp') {
$images[] = $file;
}
}Code: Select all
www.example.com/ = /html/JAM/www/
www.example.com/images/ = /html/JAM/www/images/Note that on windows it works differently, so if you are testing at home on a local server running on win32 you need to rearrange that.
so is there a solution? I don't understand what u are doing with http://www.example.com = /html/etc/etc
Hmmm
Php and webservers is actually programs on a computer, that works using the servers directory structure (among other things).
So if you go to http://www.example.com/index.html the webserver translates it into, /html/folder/whatever/foo/index.html but of course, you do not see that.
Same with PHP. When using unlink, you must be aware of that you are trying to delete a file that PHP see's as a file in a folder, on the computer.
You must provide the entire path leading to it. Meaning;
or taking your example code:
More understandable?
Php and webservers is actually programs on a computer, that works using the servers directory structure (among other things).
So if you go to http://www.example.com/index.html the webserver translates it into, /html/folder/whatever/foo/index.html but of course, you do not see that.
Same with PHP. When using unlink, you must be aware of that you are trying to delete a file that PHP see's as a file in a folder, on the computer.
You must provide the entire path leading to it. Meaning;
Code: Select all
/*
Full Address: http://www.example.com/folder/script.php
Html home directory, webserver: /html/JAM/foo/
directory using above Full Address: /html/JAM/foo/folder/
*/
unlink('file.php');
// is in theory the same as...
unlink('/html/JAM/foo/file.php');Code: Select all
<?php
unlink("/you/are/missing/directory/structure/here/" . $_COOKIE[user] . "/" . $_POST[delete]);
header("location: Http://www.slices.net/pictures.php");
?>jam, he doesn't want help. if he wanted help he would have asked something in respone tomy stating he should use absolute paths.
he wants you to write it. go check the gd thread in here. gen-ik noted that too. he attacked both gen-ik and i when we asked for him to show us some code and tell us the errors so we could understand his issue and help. his response was to directly attack me and indirectly attack gen-ik.
he even states flat out that he's using this to get fully functional code after he's had a problem. not to learn by getting advice on how to fix his issues.
he wants you to write it. go check the gd thread in here. gen-ik noted that too. he attacked both gen-ik and i when we asked for him to show us some code and tell us the errors so we could understand his issue and help. his response was to directly attack me and indirectly attack gen-ik.
he even states flat out that he's using this to get fully functional code after he's had a problem. not to learn by getting advice on how to fix his issues.
actually I just said I was sorry in that thread.. JAM thats what i've been doing the whole time .. but in the end I finally figured it out..
thanks a bunch:
for some odd reason it just works this way any other way and it says it can't find the directory.
once again sorry. 
thanks a bunch:
for some odd reason it just works this way any other way and it says it can't find the directory.
Code: Select all
<?php
$loc = "/home/virtual/site9/fst/var/www/html/";
unlink ($loc . $_COOKIE[user] . "/" . $_POST[delete]);
?>
<?
header("location: Http://www.slices.net/pictures.php");
?>