I am uploading a file to the server and at the same time I want to
place the file name in to a database.
But for the the file to be effective I need to trim the path from the
filename and leave just the filename.
Can anyone suggest how I do this?
It's all part of a google maps mash up.
The page can be found here. http://www.streetartlocator.com/dev/add_location_3.php
Thanks in advance.
Andy 8 3045
On 31 mar, 15:49, andyau <pencilsandpixe lst...@googlema il.comwrote:
I am uploading a file to the server and at the same time I want to
place the file name in to a database.
But for the the file to be effective I need to trim the path from the
filename and leave just the filename.
Can anyone suggest how I do this?
It's all part of a google maps mash up.
The page can be found here.
http://www.streetartlocator.com/dev/add_location_3.php
Thanks in advance.
Andy
in what language are you doing the job on the server side ?
if you do that with php the file name is in $_FILES['file']
['name'] ... I think
On Mar 31, 5:08 pm, Tom Cole wrote:
<snip>
I don't think PHP filesystem functions has a method to return
filepath separators (for example java does...)
<snip>
But the Java method returns the file path separator in the environment
where the JVM is executing, so probably a server where we are
concerned, but the file path originates from the browser client and so
its separator may be tied client's OS.
On Mar 31, 12:37*pm, Henry <rcornf...@rain drop.co.ukwrote :
On Mar 31, 5:08 pm, Tom Cole wrote:
<snip>I don't think PHP filesystem functions has a method to return
filepath separators (for example java does...)
<snip>
But the Java method returns the file path separator in the environment
where the JVM is executing, so probably a server where we are
concerned, but the file path originates from the browser client and so
its separator may be tied client's OS.
You are correct. Sorry about that.
I would still recommend using server side code rather than javascript
on the client for making this split. The package reference by Erwin
Moller above would be how I would probably proceed with something like
this.
Tom Cole wrote:
I would still recommend using server side code rather than javascript
on the client for making this split. The package reference by Erwin
Moller above would be how I would probably proceed with something like
this.
Me too. And it is a somewhat uncommon task for (client-side)
javascript. Normally a server program would parse this kind of data.
--
Bart
Bart Van der Donck wrote on 31 mrt 2008 in comp.lang.javas cript:
Tom Cole wrote:
>I would still recommend using server side code rather than javascript on the client for making this split. The package reference by Erwin Moller above would be how I would probably proceed with something like this.
Me too. And it is a somewhat uncommon task for (client-side)
javascript. Normally a server program would parse this kind of data.
Indeed, but that can be done using serverside javascript
as requested and on topic:
<% // javascript
var url = 'http://aa.xx/bb/cc/dd.html';
var temp = url.split('/');
var file = temp.pop();
temp.push('');
var path = temp.join('/');
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"Evertjan." wrote:
Bart Van der Donck wrote:
>And it is a somewhat uncommon task for (client-side) javascript. Normally a server program would parse this kind of data.
Indeed, but that can be done using serverside javascript
as requested and on topic:
<% * *// javascript
var url = 'http://aa.xx/bb/cc/dd.html';
var temp = url.split('/');
var file = temp.pop();
temp.push('');
var path = temp.join('/');
%>
For an URI, yes. But the specifications of a system path are
considerably different (and OS-dependent): http://en.wikipedia.org/wiki/URI http://en.wikipedia.org/wiki/Path_(computing)
Cheers,
--
Bart
Bart Van der Donck wrote:
The traditional directory separator is regular slash ('/'), but Winoid
systems generally use backslash ('\'). But a file or directory name in
UNIX may contain backslash as well.
That appears not to apply to all Unices:
$ touch '1/2'
touch: cannot touch `1/2': No such file or directory
$ touch '1\/2'
touch: cannot touch `1\\/2': No such file or directory
$ mkdir '1/2'
mkdir: cannot create directory `1/2': No such file or directory
$ mkdir '1\/2'
mkdir: cannot create directory `1\\/2': No such file or directory
$ uname -a
Linux pointedears 2.6.17.13-20060915.184752 +0200 #1 PREEMPT Fri Sep 15
19:07:16 CEST 2006 i686 GNU/Linux
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Thomas 'PointedEars' Lahn wrote:
Bart Van der Donck wrote:
>But a file or directory name in UNIX may contain backslash as well.
That appears not to apply to all Unices:
$ touch '1/2'
touch: cannot touch `1/2': No such file or directory
$ touch '1\/2'
touch: cannot touch `1\\/2': No such file or directory
$ mkdir '1/2'
mkdir: cannot create directory `1/2': No such file or directory
$ mkdir '1\/2'
mkdir: cannot create directory `1\\/2': No such file or directory
$ uname -a
Linux pointedears 2.6.17.13-20060915.184752 +0200 #1 PREEMPT Fri Sep 15
19:07:16 CEST 2006 i686 GNU/Linux
Your test only indicates that UNIX filenames cannot contain forward
slash. This is logical, because that character is reserved as
directory separator. I don't see any problems with backslash here:
%ls -l
%touch '1\2'
%ls -l
total 0
-rw-r--r-- 1 bart users 0 Apr 3 10:21 1\2
%uname -smr
FreeBSD 4.8-STABLE i386
%
Backslash handling might depend on the shell:
%echo $SHELL
/bin/csh
%
--
Bart This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter A. Schott |
last post by:
Got a strange scenario going on here in that I could have sworn this worked
yesterday. I am issuing binary retrieval calls to an FTP server, writing to a
file, close the file, then removing the file from the remote site. When I do
this, I end up with 0 byte files. I was hoping to avoid parsing a list of
remote and local files and matching them up that way because it would be easier
to remove on successful retrieve. I'm including some...
|
by: Joe Laughlin |
last post by:
If I have a character array with "/some/file/directory/file_name", are there
any functions / libraries that I could use to separate the directory
("some/file/directory") from the file name ("file_name").
I looked at sscanf(), but that didn't seem to do what I wanted.
Thanks,
Joe
|
by: moondaddy |
last post by:
Using vb.net I need to download image files to the client browser where they
can save to disk. Below is some sample code I'm using. when I run this the
File Download window in the browser says:
File name: ViewAttachment
File type:
From localhost
1) "ViewAttachment" is the name of the aspx page and not the image file.
2) Its not picking up the file type of jpg. For ContentType I used
|
by: BW |
last post by:
I am creating an upload/download function for an extranet site. Files will
be uploaded to directory based upon the users login and associated project.
The function works as long as I use "c:\Temp" as the directory. When I use
any other hard coded directory or even Server.MapPath() the upload function
fails and returns the error: "Exception has been thrown by the target of an
invocation." Once I change the root directory to "c:\Temp",...
|
by: Rob |
last post by:
I want to copy files from one folder to another... but only if it is a
".txt" file...
Below should work, but how would you filter on ".txt" files only ?
Thanks !
Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
' Process the list of files found in the directory.
Dim fileName As String
| |
by: Hitesh |
last post by:
Hi,
I have a small script here that goes to inside dir and sorts the file
by create date. I can return the create date but I don't know how to
find the name of that file...
I need file that is not latest but was created before the last file.
Any hints... I am newbiw python dude and still trying to figure out lot
of 'stuff'..
|
by: garyusenet |
last post by:
Hi i would like to trim a text string.
I have a text string called filename
I want to display just the file in my label, and not the path.
Can someone tell me how I get everything AFTER, the LAST, BACKSLASH in
the string please?
Thankyou
|
by: Krustov |
last post by:
I have the following list of image files .
When searching the latest (numbered file) in this particular case its
background_4.*** and its a .jpg file - but - the latest file in the list
could also be a .gif file at times .
zimages_background/background_1.jpg
zimages_background/background_2.jpg
zimages_background/background_3.gif
zimages_background/background_4.jpg
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script.
What You Need
Any recent...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |