Results 1 to 4 of 4

Thread: Stat failed message using stat() functions

  1. #1
    Join Date
    Oct 2008
    moreno valley, California ,usa

    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
    ... then

    if($num>0) {
    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');
    mkdir($pic_folder, 0777);
    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?


  2. #2
    Join Date
    Aug 2004
    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.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Nov 2008
    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.

  4. #4
    Join Date
    Oct 2008
    moreno valley, California ,usa
    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.

    PHP Code:

    //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());
    '<h3>There was a problem retrieving picture and folder info from teezers</h3>';

    //set up the path to the picture folder
    $filearray as $file)
    '<h3>This is a folder</h3>';
    //end while

    //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_folder0777);//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());  
    $num>1) {
    '<div class="error_occur"><h3>The catalogue number you have chosen is already in use; please choose a different number.</h3></div>';
    'duplicate catalogue number has occurred');
    mkdir($pic_folder,0777);//permission denied
    As you can see, I've slapped a '0777' permission setting on everything I can think of that might be relevant.
    Thanks in advance.
    Last edited by captsig; 08-06-2010 at 12:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13603 seconds
  • Memory Usage 2,908KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates