Page 2 of 2
Posted: Mon Oct 27, 2003 5:16 pm
by nick2
OMG... DOES IT MATTER?
I ASKED TWICE HOW CAN I FIX MY OTHER PROBLEM MAYBE YOU WOULD LIKE TO DISCUSS THAT INSTEAD OF SOMETHING THAT DOESN'T MATTER?
its so small yet its causin so many problems..
Posted: Mon Oct 27, 2003 5:30 pm
by m3rajk
nick2 wrote:why won't this work?
code:
Code: Select all
<?php
unlink("/" . $_COOKIE[user] . "/" . $_POST[delete]);
header("location: Http://www.slices.net/pictures.php");
?>
errror:
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
your second is a result of the first
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/
Posted: Mon Oct 27, 2003 6:24 pm
by JAM
Not because it matters much perhaps, but I'm adressing the first question just to make it noted:
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;
}
}
Using unlink like that wont probably work as you are working on server structure rather than www-address structure.
Code: Select all
www.example.com/ = /html/JAM/www/
www.example.com/images/ = /html/JAM/www/images/
...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.
Posted: Mon Oct 27, 2003 7:24 pm
by nick2
so is there a solution? I don't understand what u are doing with
http://www.example.com = /html/etc/etc
Posted: Mon Oct 27, 2003 7:40 pm
by JAM
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;
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');
or taking your example code:
Code: Select all
<?php
unlink("/you/are/missing/directory/structure/here/" . $_COOKIE[user] . "/" . $_POST[delete]);
header("location: Http://www.slices.net/pictures.php");
?>
More understandable?
Posted: Mon Oct 27, 2003 8:21 pm
by m3rajk
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.
Posted: Mon Oct 27, 2003 8:26 pm
by JAM
I noticed also, but didn't want to belive it. I wanted to give it a shot, but the above post was my last on the subject.
Posted: Mon Oct 27, 2003 9:18 pm
by nick2
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.
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");
?>
once again sorry.
