Stat failed message using stat() functions
Hello fellow coders,
this is probably a tiresome topic for many of the more competent designers, but I am again confronting a "failed to open streamermission denied" message when trying to create a directory.
One file creates a directory and allows the upload of pictures into it. No problems here. But another file allows the viewer to change the name of the folder and up load different pictures. In this program, I get the permission denied problem when the routine hits the creation of a new directory.
In trying to attack the problem I am trying to use functions to tell me the various kinds of information on the file; but these functions too are giving me problems.
For example, in the first part of the process where I am not having any problems, I tried to use the following functions to see what the file owner and permissions were at time of creation of the directory:
...because the picture folder name is the product item name, I check to make sure it is unique
echo '<div class="error_occur"><h3>The part name you have chosen is already in use; please choose a different name.</h3></div>';
exit('duplicate picture file name has occurred');
echo '<h3>The file user is:'.' '.$user['name'].'</h3>';
echo '<h3>The file permissions are:'.' '.decoct(fileperms($cur_dir)).'</h3>';
the error message says fileowner(..) failed and fileperms failed and the printed line says file permissions are : 0
Anyone have any suggestions?
What happens if you use $pic_folder in those lines instead of $cur_dir? (If you just use the basename() value, then it's going to look for it as a file or directory in the same directory where the script is running.)
PS: If you wrap your code snippets here in the [php]...[/php] tags, it makes it a lot easier to read.
Also fileowner() returns an int not an array (which isn't the cause of your issue but it won't do what you want if NogDog's suggestion works)
The first rule of Tautology Club is the first rule of Tautology Club.
NogDog and Mindzai,
thank you for your responses; NogDog's suggestion worked on the first file that initially creates the picture folder; however on the second file that allows the viewer to change the folder and pictures within, I'm back to getting the 'stat() failed message along with 'permission denied' at the point I want to create a new picture folder.
I thought I would drop in the relevant code section; I made comments to help clarify what I am trying to do. If anything jumps out at you, please let me know.
As you can see, I've slapped a '0777' permission setting on everything I can think of that might be relevant.
//if submitted -process the form input otherwise display the form
//remove the current picture folder and picture files
$query3="SELECT item_name, img_lg, img_sm FROM teezers WHERE catnum='$item'";
$result3=mysql_query($query3) or die(mysql_error());
echo '<h3>There was a problem retrieving picture and folder info from teezers</h3>';
//set up the path to the picture folder
foreach($filearray as $file)
echo '<h3>This is a folder</h3>';
//now create a new folder for the new uploaded pictures
$user=fileowner($pic_folder);//warning: stat() failed
echo '<h3>The file user is:'.' '.$user['name'].'</h3>';//printed out as a blank
echo '<h3>The file permissions are:'.' '.decoct(fileperms($pic_folder)).'</h3>';//printed a zero and warning stat() failed
chmod($pic_folder, 0777);//warning: permission denied
//check to see if the item name already exists in the database, if not create a folder by that name
$query="SELECT * FROM teezers WHERE catnum='$catnum'";
$result=mysql_query($query) OR die(mysql_error());
echo '<div class="error_occur"><h3>The catalogue number you have chosen is already in use; please choose a different number.</h3></div>';
exit('duplicate catalogue number has occurred');
Thanks in advance.
Last edited by captsig; 08-06-2010 at 01:07 PM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)