473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Retrive the folder name

190 100+
HI,

See the sample

$basedir = C:\Documents and Settings

$fileuploadpath=C:\Documents and Settings\folder1\folder2\abcd.jpg
(or)

$fileuploadpath=C:\Documents and Settings\folder1\folder2\abcd.jpg

I want to retrieve the name of folder1 or/and folder2 between the $basedir and $fileuploadpath....

How can i find ? (May number of folders come between $basedir,$fileuploadpath)
Jun 5 '08 #1
6 1346
hsriat
1,654 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. $directories = explode("/", str_replace($_SERVER['DOCUMENT_ROOT']."/", "", str_replace("\\","/",getcwd())));
  2. print_r($directories);
See if you want this.
Jun 5 '08 #2
maheswaran
190 100+
sorry where i give my $fileuploadpath ... If am given in $_SERVER[Document_root]...Is not work just am getting like this

"C:Program Filesxampphtdocsprojectfolderimport"
Jun 5 '08 #3
maheswaran
190 100+
Am getting $basedir and $fileuploadpath while uploading a file

I want to retrieve the name of folder1 or/and folder2 between the $basedir and $fileuploadpath....


like

basedir: C:/document
fileuploadpath: C:/document/foldernamesample/upload.gif

i want retrive only the foldernamesample
Jun 5 '08 #4
Markus
6,050 Expert 4TB
Am getting $basedir and $fileuploadpath while uploading a file

I want to retrieve the name of folder1 or/and folder2 between the $basedir and $fileuploadpath....


like

basedir: C:/document
fileuploadpath: C:/document/foldernamesample/upload.gif

i want retrive only the foldernamesample
[php]
<?php
$loc = str_replace("\\", "/", $_SERVER['SCRIPT_FILENAME']);

$parts = explode("/", $loc);

echo $parts[count($parts) - 2];
?>
[/php]
Jun 5 '08 #5
Atli
5,058 Expert 4TB
Like Markus' example shows,
Using the explode() function to split a file path on the / char (or \ on Windows), all the resulting elements except the first and last would be folder names. You would just have to point to the element you need.
Jun 5 '08 #6
maheswaran
190 100+
Thanks.But if case like this
C:/document/foldernamesample1/upload.gif
C:/document/foldernamesample1//foldernamesample2/upload.gif
C:/document/foldernamesample1//foldernamesample2/foldernamesample3/upload.gif

Then it's not work.. That am said above any number of folders come between basedir and fileuploadpath...
Jun 6 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: hariramasubbu | last post by:
Hi Environment:IIS6,ASP.Net on windows 2003 server. Problem:Try to retrive the users first and last name from his NT Logon id. I use HttpContext.Current.User.Identity.Name to get...
2
by: Goran | last post by:
I'm a student and I've just started to learn Visual Studio.NET. I have a project to make a web application. I have a problem to connect to the database and retriving the PassType of the...
2
by: Patrick F | last post by:
Hi, i have a resourcefile with my project that contains a jepg image. Now i want to retrive that image to a Image m_Image in my program. Whats the best way to do this?
3
by: poolieweb | last post by:
I have created a custom user control which creates a ASPxMenu ( Same fucntion as standard menu control) from data retreved from a webservice (Reporting Services) which deals with user access. This...
23
nehashri
by: nehashri | last post by:
hi i am designing a database using Ms Access and ASP. i have 3 tables in access namely 'PERSONAL', other as 'POLICY' and 3rd one is named as 'STAFF'. in the contact table i have ID, Name, Children...
2
idsanjeev
by: idsanjeev | last post by:
hello how can retrive the input text after submit button pressed and report a error message. i wants to post topic and if any error message is occured then retrive the inputed text but it forget its...
1
idsanjeev
by: idsanjeev | last post by:
hello i wants to retrive data in textarea like input text but in textarea value is not work so what should be use to retrive textarea value after any error <input type="text" name="name"...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
0
by: gopim | last post by:
i uploaded a file to a folder,but i want to retrive file from folder and also that file format will be same means what i uploaded that file extension only i want retrive.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.