Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Check If Object In Directory Is File Or Folder?


Using PHP, I want to check if a object in a directory is a file or folder like:

filetype();

Above function works, however I think filetype needs to be installed optionally?




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Directory List, Identify Folder Different Than File
I need to make the folder from my dir lister point to a link different of my files ?

I'm working with windows NT server... and php 4.3.2

Here is my code :

<?php
$file = $_GET['file'];
if(isset($_POST['text']))
{
if(get_magic_quotes_gpc())
{
$_POST['text'] = stripslashes($_POST['text']);
}
$handle = fopen($file, 'w') or die("Unable to open file for writing");
fwrite($handle, $_POST['text']);
fclose($handle);
}

$text = "";

if(is_readable($file))
{
$text = file_get_contents($file);
}
?>

And later on the page in the html part :

<textarea class="zz" name="text" id="text" cols=170 rows=10 wrap="off"><?php echo $text; ?></textarea></td></tr>

and to add anothe challenge I need it to open in another frame wich is the verticaly siding this one.

View Replies !   View Related
Copy A File To Folder In Apache Directory From Html Form
Does anyone have a PHP script that will take a file uploaded by a user via a HTML form, i.e.:

<input type="file" name="filename" id="filename" class="textbox">

Take the file and copy it into the Apache directory on the server?

i.e. on my local machine Apache2.2/htdocs/mini/images/*FILEINHERE*

View Replies !   View Related
Check A File Exists In Another Directory
I am writing a script that will insert a link to the page, but before it does that, it must check to see if the page exists. I can use the file_exists($page_file) function, but it seems to only work if the file is in the same directory where the script executes. My script is supposed to find the script in another directory, but it does not find them and returns false. Does anyone know how to solve this problem?

View Replies !   View Related
Programatically Check If File Exists In The Directory?
I have a file name and a directory with hundreds of files. How can I programatically check if this file exists in the directory?

View Replies !   View Related
PHP4 -> PHP5: Require Does Not Check File Directory Anymore?
In my application I have lots of require statements that include files
residing in the same directory:

index.php requires:
require_once($_SERVER['DOCUMENT_ROOT']."/modules/cms/classes/page.php");

page.php requires:
require_once("common_functions.php");

Now I try to install the application on a PHP5 server (Apache), and this
does not work anymore.

In the PHP4 -> PHP5 migration chapter of the manual I did not find any
notes on a change of the require/include behaviour, not checking the
directory of the calling file anymore; nor did I find it googling. So I
am not sure if it is an undocumented migration issue or just a setting.

I understand that I can use:
require_once(dirname(__FILE__)."/common_functions.php");

But this means rewriting the whole application. Is there a way to change
this behaviour via ini_set()? (As I am in a shared hosting environment I
have no direct access to the php.ini.)

View Replies !   View Related
Check For Folder
how would i check if there's at least one folder in the current folder? the current folder is $dir/$f/

this is what i have, but i know its wrong

$fillle = "$dir/$f/";
if (file_exists($fillle)) {$Q="true";} else{$Q="false";}

View Replies !   View Related
Check If A Folder Contains Anything
what do I use to check if a directory contains anything.

For example how do I check if there is anything in this? (Which in english is something like news/download/may2007/document1.doc

UPLOADS_PATH.'/news/download/'.$oDownload->download_path.'/'.$oDownload->download

View Replies !   View Related
Creates A Temporary Folder And A File Within The Folder.
I have a PHP script which creates a temporary folder and a file within the folder.

I have a problem when trying to remove the file and folder using my FTP program. The ownership and group are set to NOBODY. I cannot change the permissions on either the file or the folder.

I have tried chmod and chgrp and chown but for some reason I cannot change permissions.

View Replies !   View Related
Error Check - Chmod This Folder To 777
i am getting this following error

Warning: fopen(c:/wamp/www/phpfile/Scripts/adminpanel/TABLE_PREFIXdb.php): failed to open stream: No such file or directory in C:Program FilesApache GroupApache2htdocsinstall.php on line 84

Unable to create TABLE_PREFIXdb.php in adminpanel. Please chmod this folder to 777 and press refresh on this page. any one can tell me way out?

View Replies !   View Related
Check Windows Folder Permissions
I'm writing some PHP code which acts as a web-based file browser. It lists all the directories and files on a server by checking the server directly rather than going through FTP.

The files and directories on the server have permissions which restrict them to certain users. What I want the code to do is check if the user who is currently logged in has permissions on the file or directory and if so, check if the permissions are sufficient enough tpo perform the requested operation. Code:

View Replies !   View Related
List Of My Files Within A Folder / Directory
how can i create a dirlist.php file so i can view just a list of my files within a folder of my website?? So just the files are listed?

View Replies !   View Related
Check Folder Name, If True, Include This Code
I need to check if the folder name is equal to for example, "Food", then do something, else don't do anything.

View Replies !   View Related
Create A Folder In A Directory One Level Up On A Linux
I am trying to create a folder in a directory one level up on a Linux
based Apache server from the file containing the following line.


The followin line doesn't seem to achieve this.

mkdir("./members_pics/"."$subscr_id"."/", 0700);

View Replies !   View Related
File In Folder Above Root Folder
I have a .php script in a folder one level above my website root, and I'd like to include it in pages in various website subfolders, some below the root. Can I use ($_SERVER['DOCUMENT_ROOT'] in the path in some way.

View Replies !   View Related
Internet Explorer 6 Vs 7 : COM Object That Uses ADSI To Reset Active Directory Domain Accounts
Setup: IIS 6 with PHP 5.2.0

We are trying to make a COM object that uses ADSI to reset Active
Directory domain accounts. We can get the script to work great in
IE7, but anyone stilll using IE6 has problems. We are using
authentication (IWA and IIS configured not to allow anonymous) via the
browser.

I also have the same problem with a simple example script off of php's
site (http://us3.php.net/com)

<?php
$domainObject = new COM("WinNT://Domain");
foreach ($domainObject as $obj) {
echo $obj->Name . "<br />";
}
?>

In Internet Explorer 6 I just get "Schema". With IE7, I get the full
list of objects...

View Replies !   View Related
Using Php To Check User Directory
anyone knows how to check whether a person in a virtual community is online using php? can someone tell me the logic to work this out?

View Replies !   View Related
Check If Directory Is Empty
I've made a script that puts images in a certain directory into the database. With the following code.

View Replies !   View Related
How To Check Files In A Directory
I have a txt file in a directory that I want to display on my website with PHP, that's no problem. Say that every hour later, a new txt file gets uploaded to the directory.

1) How can PHP display ALL the text files on a webpage in order from latest to first?

2) This can be done manually by just changing the PHP code every hour, but is there a way so that I don't have to change the code everytime a new text file gets added, so that its done automatically?
(ie. how can it check for new files to show?)

View Replies !   View Related
How To Check Which Is My Current Directory ?
If I go to a link like http://localhost/links/computer/
the page does not find the css files.
Only if I set
<link rel="stylesheet" type="text/css" href="http://localhost/main.css">
in the header it is loaded.

The other content however included via php is found somehow.

View Replies !   View Related
Check If Directory Empty
I have the following code in the efforts of checking if a directory is empty before using rmdir. I'm doing something wrong but don't know what. What's wrong with my code below, or is there a better way to check if a directory is empty other than readdir? PHP Code:

$OpenDir=opendir("../../Audio-MP3/Uploads/".$WebPage."/". stripslashes($Row["Directory"]));
        if (readdir($OpenDir)<>""){        
            if(is_dir("../../Audio-MP3/Uploads/".$WebPage."/". stripslashes($Row["Directory"]))){
                rmdir("../../Audio-MP3/Uploads/".$WebPage."/". stripslashes($Row["Directory"]));
            }
        }

View Replies !   View Related
Include Or Require A File From A Protected Directory And Maintain The Directory's Access Control?
I have an htaccess protected directory and I'm accessing a file in it through a require "admin/admin.php"; command (admin being the protected directory). I was hoping for the username and password popup window, instead I got direct access to my file.

Is there another way to include or require a file from a protected directory and maintain the directory's access control??

View Replies !   View Related
Check A Directory For Files To Import
I want our company employees to be able to update our website with special formated emails. My IT guy has made a perl script to parse the email to a text file formatted the way I want.

I want him to dump the txt file into a directory, that is being watched. When a new file is put there, I want something to pass the name onto my PHP script, so it can run, and import the file into mySQL. My PHP script works if I tell it what the name of the file is, but I have to execute the script myself. I am not sure if I can use PHP to monitor the folder for new files, or if I need to use a crontab, or what?

View Replies !   View Related
Which Path For Filemtime To Check Whole Directory?
I'm using this code to display the last time any page of my site was updated:

putenv("TZ=America/Los_Angeles");
echo "Site last updated: ".date("dS F Y h:i A", filemtime("/path/to/directory/."))." (PST).";

...but I'm not sure what to change the /path/to/directory/ to...

Is it the path as I see it in my FTP - that doesn't seem to work?
What does leaving a mere dot there mean?

Does filemtime(".") mean 'everything in the current directory'?

View Replies !   View Related
How Can I Include A File Relative To The Top Level Directory From Any Other Directory ?
How can I include a file relative to the top level directory from any other
directory ?
I really hate to use absolut url or put all my files in one directory.

eg : include("<symbol for top>/somefile.php"); ?

View Replies !   View Related
Load .txt File From Computer And Save The File In Www/folder Director
anyone know how to add the .txt file from computer into the localhost www/Myfolder directory.

View Replies !   View Related
File Check-in/check-out System?
I'd like to a build a PHP-based interface for sharing documents (MS Office docs, latex, etc). I need to be able to allow users to "check-out" the files for their exclusive use and then go through a "check in" process when they re-upload the doc so it's accessible again to everyone else.

I'd also like to implement some form of version control where older versions of the docs can be in some sort of repository. I'm not quite sure how to approach either concept. I'm wondering if anyone can give me tips on how I might go about this.

View Replies !   View Related
Upload File And Save The File Into One Of Folder
I'm trying to solve problme with upload file, one this scripts is to uplaod file, is works great but something missing myself that the file is missing not sure where they save to. I just need help where to write code to save the file into one of folder in C drive. Code:

View Replies !   View Related
How Do I Add A New File To A Folder?
Say I want to add a file named 123.php to the folder /xxxx/ How would I do that using php and a form? Is there a function or a tutorial?

View Replies !   View Related
Check The File Mimetype To Validate If The Uploaded File Is In The Correct Format
I used PHP to upload some flash files. Here, I want to check the file mimetype to validate if the uploaded file is in the correct format. But, when I am uploading .flv (flash video file), PHP returns the mime-type as "application/octet-stream". :confused::confused:

According to my research, flv should return video/x-flv. Please anyone help me to get it working correctly?

View Replies !   View Related
How To Protect A File Or Folder?
I want to protect my URL
How to realize the following function?
Users click on the URL, a login htm page appears. Users enter username, password and click on the submit button. PHP file consults mySQL to get username, password and registration date. If user account is valid, user may download this software.

View Replies !   View Related
Folder/File Perms...
I made a PHP script that creates a new folder (say "Folder 1") and then copies a file from the parent folder (call the file "index.php") into the new folder; so we get Folder 1/index.php

Now, how can I set the ownership of this file and folder, automatically via the PHP script, to me (the server user), not httpd?

View Replies !   View Related
Seperate Folder For File
I have written a form that accepts information and a file.  It currently writes the file to the database table also but I would like it to write the file to a seperate folder but keep the relationship with the other information so it can be searched and retreived later.

Also how would I go about allowing for mulitple files to be uploaded and linked to the table information? Here is the scrip I wrote for the upload to happen: Code:

View Replies !   View Related
File/folder Permissions
I have an upload function that uploads images into a folder. The folder is set to 777. However when I upload an image file to the folder, the file uploaded is set to 600. Therefore it wont appear on web. I'm not sure why this is doing this for??  Im using the php function move_uploaded_file to upload the file.

View Replies !   View Related
Searching File In Folder
I want to ask how can I list all the files and folders inside a given directory. example:

C:Documents and Settingsuser11My Documents
is the directory. I want to get all the files and folders name inside it.

View Replies !   View Related
Php Folder & File Creator
But what I would like to do is have a php form (eg back end manager) that i can fill in with:

file name
folder name
todays date
page title
page body text

And when you click the submit button it creates the folder with the name I specified and with in that folder it creates the .php page with the other info that i put into the form.

I've found scripts that will create the page, but not the folder. Is it possible? or should I find another way round this eg database and a backend manager.

View Replies !   View Related
File Upload To New Folder
On uploading file.., the file moves into the temp dir "C:Windows Temp" which is not accessible in the server.

Is there any way to store the uploaded files in a new directory and then move it to desired directory?

View Replies !   View Related
File Exist In Folder
I was wondering what kinda script i need if i want to look inside a folder to see if there is a certain image.

Ex :

If (there is an image in this folder called $row['image']) {
}show the image;
}else{
print "there is no image"'
}

As you can see, I am taking the image from a DB, I will loop this whole script so that it'll show only if there is an image associated with my record.

View Replies !   View Related
Redirect Folder To File
I'd like to redirect from any address in a folder to a specific file.

From
www.mydomain.com/something.html
or
www.mydomain.com/something_else.html
to
www.mydomain.com/2006/index.php (or www.mydomain.com/2006/)

I believe that this can be done with mod_rewrite and/or htaccess, but I have no clue. Can you provide a real example/ code, please?

View Replies !   View Related
Open A File In The Cgi-bin Folder
I have Apache/MySQL/PHP on Windows XP. If I try to open a file in the cgi-bin folder, I will get a 404 error. If I try to open the same file not in the cgi-bin folder, I will not get a 404 error.

View Replies !   View Related
Copy A File On Folder
I have a script that creates a folder in my site when someone registers. I need a file that is stored on my site to be copied into this newly created folder every time a folder is created. I also need a new empty folder to be created in this folder with a standard name. So, when someone registeres on my site, I have a script that creates an ftp account and folder on my site for them using the info they provided, but what I need is a file copied to that folder and a sub folder created.

View Replies !   View Related
Moving A File From One Folder To Another
i am trying to work out the syntax for a statment for moving a file from folder a to folder b on my server e.g my files called "26a.jpg" and I want to move it from "foldera" to "folderb"

View Replies !   View Related
Folder-file Manager
I'm trying to create a simple file manager. The problem that I'm facing right now is how to create folders within folders (subfolders) and store them virtually in mysql and not on the filesystem.

View Replies !   View Related
Upload Folder Not File
My client wants a php script which allows the user to not upload a single file through the filefield in a form, bu to upload an entire folder.

I told him I thought this wasn't possible, but I like the idea. I searched the net and all I found was that it is impossible to retreive data from a local folder.

e.g. readdir only reads dirs from the server, it I could somehow index the local folder, I could loop the files tp upload, but this seems to be impossible to do.

I was wondering if anybody has any experience or info on getting files from a clients hard disk?

View Replies !   View Related
Referencing A File Or Folder
I'm trying to point to an include file from php like so:

<?php require('/main/includes/nav_stripe.php');?>

That approach is perfectly fine when trying to point to a folder INCLUDES inside folder MAIN on the root IN HTML. However, php is producing errors. Is there a solid safe way to reference a file/folder regardless of how many levels up or down it is.

View Replies !   View Related
File Upload :: Warning: Fopen - No Such File Or Directory
I’m getting the following errors when I try to run the script below on a live server. It’s a crude script which uploads text and images directly into MySQL. It works fine on my local machine, I have Apache, PHP4 and MySQL running on windows. The live server is Unix.

When I try to upload images from my loacal pc I get the error below, when I placed an image file within the same directory as the script on the live server and tried to upload it that worked. I wanted the script to allow image uplload from a client pc Can anyone offer a suggestion?

Warning: fopen("C:Apachehtdocs Grey.jpg", "r") - No such file or directory in /usr/local/home/httpd/vhtdocs/sitehostin/moondance/backend/test_imagedb.php on line 57
Code:

View Replies !   View Related
Php File To Call On A File In A Password Protected Directory
Does anyone know is I can have php file calling on a file in a password protected directory (through basic authentication)?

View Replies !   View Related
Upload A File To A Folder In My C: Drive
I am trying to upload a file to a folder in my c: drive but i get a stupid error I am doing this for the first time. Can anyone send me a simple script to upload a file to a folder? Code:

View Replies !   View Related
Moving A Existing File From One Folder To Another
Lets say i have a file with the name atest.doc and its in the directory www/directory1
but i want to move that file using php to www/directory2/ how do i do this
i tried

move_uploaded_file()

View Replies !   View Related
Create A Zip File Of The Contents Of A Folder?
Im wondering if there is a way, through a php script, to create a zip file of the contents of a folder?

E.g. the web user would submit a form, and after a bit of validation, a zip file would be created, and a download forced.

How could would i go about creating the zip file through php?  (Im hosted on a Windows mashine)

View Replies !   View Related
Require File In Folder Above Public_HTML.
I have a functions file in my /home folder. My web directory in /home/public_html/ .

I have a header file in /home/public_html/assets/includes/header.php .

The top line on the header.php is
<?php
require("../../databases.inc");
?>

The problem is that whenever I include my header in a folder (ie. /home/public_html/videos/index.php) it will not get the databases.inc file as its now looking in public_html instead of my /home folder. Is there any function in the $_SERVER functions or anything simliar to detect how many folders it has to navigate to inorder to find the functions file?

View Replies !   View Related
File Upload With Create Folder
I am trying to have a file uploaded into a directory, based on user input. If the folder they are uploading to doesn't exist, it is created. The only thing I can think of, is that this method of file uploading will only work to 1 folder deep. That is only a guess though. Also the "destination" will only be 1 word long. Code:

View Replies !   View Related
Include File In Parent Folder
I want to include a certain file that's in a parent folder.  For example, the file "config.php" is located in public_html/ and the file i'm including it in is in public_html/admin/  How do I include public_html/config.php in public_html/admin/index.php?

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved