Go to Post Safety glasses may be a nice forehead protector, but thats not what they are made for. - Quatitos [more]
Home
Go Back   Chief Delphi > Technical > IT / Communications > Website Design/Showcase
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-12-2004, 07:53
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
PHP file system stuff

Couple 'o php questions.
  • How can I tell what files/folders are in a directory?
  • How can I tell if a file exists without making two calls to fopen()? (assuming I then want to open it for read)
__________________

  #2   Spotlight this post!  
Unread 01-12-2004, 09:22
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
Re: PHP file system stuff

1) scandir()
2) file_exists()
__________________
Brandon Martus
e-mail
  #3   Spotlight this post!  
Unread 05-12-2004, 14:46
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: PHP file system stuff

So, I'm trying to remove a directory here...

Windows XP system running Apache 2.0.50 with PHP 4.3.9. (Yes, I know that 2.0.52 is out. Upgrade is coming soon.) I'm trying to remove a directory which is located relative to the current one at ../pages/<dir>. I'm able to delete all the files in the directory, but on trying to remove the directory itself I get a "Permission denied" error.

Here's the exact code which applies:
PHP Code:
...
        
// Ensure the directory only contains the struct file (and the current and parent dir references)
        
if(!(count(scandir("$dir/pages/$_POST[cat]")) <= 3))
        {
            
header('Location: /index.php?section=admin&page=failure');
            die();
        }
        
        
// Remove struct file
        
if(file_exists("$dir/pages/$_POST[cat]/struct") && !unlink("$dir/pages/$_POST[cat]/struct"))
        {
            
header('Location: /index.php?section=admin&page=failure');
            die();
        }
        
        
// Remove the directory
        
if(!rmdir("$dir/pages/$_POST[cat]"))
        {
            
header('Location: /index.php?section=admin&page=failure');
            die();
        }
... 
The struct file is just a file which is used by other parts of the site to maintain the directory structure. (The entire site is just a pre-alpha type thing for learning PHP and eventually some of the code will go into our team's site. The main thing is a user can login and edit content pages over the web.) The struct file does get deleted successfully; I see it disappear in my little Windows Explorer window. $dir contains a path which is brings the path back to the root of the site before going deeper in. In this case, it equals "./..". (The reason for the ./ at the beginning is how I generated it. I was too lazy to remove that part of it, as it shouldn't make a difference. Does it?)

I'm using pretty much the ship configuration which is in the php.ini-dist.recommended (or whatever that file was called) file.

Ideas? Was I unclear?
__________________


Last edited by Ryan M. : 05-12-2004 at 15:06.
  #4   Spotlight this post!  
Unread 06-12-2004, 07:36
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: PHP file system stuff

And maybe this is related:

Using the code below (I had something in a different file, but I wrote this stuff out just for testing. I get the same results with both things.) I get... nothing. The page just appears again without the slightest hint it did anything. Actually, on the other one, I have more error checking and it catches that the move_uploaded_file() fails and reports it appropriately.

Here's the test code:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<?php
    
if(isset($_POST['image']))
    {
        echo 
$_FILES['image']['tmp_name'];
        
move_uploaded_file($_FILES['image']['tmp_name'], "./$_POST[name]");
        echo 
"<img src='./$_POST[name]' />";
        echo 
"<img src='./$_FILES[image][tmp_name]' />";
    }
?>

<form method="post" action="test.php" enctype="multipart/form-data">
<table>
    <tr>
        <td>File:</td>
        <td><input type="file" name="image" /><input type="hidden" name="MAX_FILE_SIZE" value="40000" /></td>
    </tr>
    <tr>
        <td>Save as:</td>
        <td><input type="text" name="name" /></td>
    </tr>
</table>
<input type="submit" value="Upload" />
</form>
</body>
</html>


--EDIT--
Acutally, after adding the enctype="multipart/form-data" to the form, I now get nothing. It just reloads.
__________________


Last edited by Ryan M. : 06-12-2004 at 07:43.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What do you wish you knew about the new control system? Joe Ross Control System 2 09-01-2004 21:47
openFIRST switches debugging system to Bugzilla Timothy D. Ginn FIRST-related Organizations 0 28-12-2003 00:32
Need a FIRST Robotics control system kershawrobotics General Forum 3 07-07-2003 09:49
Current Monitoring system questions PyroPhin Technical Discussion 44 17-02-2003 15:34
who can we buy stuff from?!?! archiver 2001 7 23-06-2002 23:04


All times are GMT -5. The time now is 00:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi