473,394 Members | 1,748 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,394 software developers and data experts.

trim filename from a string

I am receiving a string which has in it a full path of the file the
user entered in a previous form. I would like to trim just the file
name from this string.
So rather than having users/andy/images/image.jpg I insert only
image.jpg in to my database table.

I am receiving this as a string not as a multipart form submit the
file has already been placed on the server by this stage.

Thank you in advance for any help.

Cheers
Andy
Apr 1 '08 #1
3 1769
In our last episode,
<64**********************************@q27g2000prf. googlegroups.com>,
the lovely and talented andyau
broadcast on comp.lang.php:
I am receiving a string which has in it a full path of the file the
user entered in a previous form. I would like to trim just the file
name from this string.
So rather than having users/andy/images/image.jpg I insert only
image.jpg in to my database table.
see pathinfo() in the manual.
I am receiving this as a string not as a multipart form submit the
file has already been placed on the server by this stage.
--
Lars Eighner <http://larseighner.com/us****@larseighner.com
Countdown: 294 days to go.
Apr 1 '08 #2
<comp.lang.php>
<andyau>
<Tue, 1 Apr 2008 03:45:26 -0700 (PDT)>
<64**********************************@q27g2000prf. googlegroups.com>
I am receiving a string which has in it a full path of the file the
user entered in a previous form. I would like to trim just the file
name from this string.
So rather than having users/andy/images/image.jpg I insert only
image.jpg in to my database table
<?php $temp=basename($_SERVER['PHP_SELF']); ?>
--
www.krustov.co.uk
Apr 1 '08 #3
I currently have

$photo = basename( $_GET['myfile']['name']);

also tried $temp=basename($_SERVER['PHP_SELF']);

Changing the relevant elements.

The element that is coming in on the string is myfile and what is
being inserted into the database is photo.
On Apr 1, 12:40 pm, Krustov <m...@privacy.netwrote:
<comp.lang.php>
<andyau>
<Tue, 1 Apr 2008 03:45:26 -0700 (PDT)>
<64a6e4c0-de94-4db5-ab67-01c955eb1...@q27g2000prf.googlegroups.com>
I am receiving a string which has in it a full path of the file the
user entered in a previous form. I would like to trim just the file
name from this string.
So rather than having users/andy/images/image.jpg I insert only
image.jpg in to my database table

<?php $temp=basename($_SERVER['PHP_SELF']); ?>

--www.krustov.co.uk
Apr 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Christopher Brandsdal | last post by:
How do i cut the last 4 characters in a string? I know how to cut the 4 first, but i need to cut the last! I have a image name like testimage.gif and I want to cut away .gif Thanks...
22
by: Simon | last post by:
Hi, I have written a function to trim char *, but I have been told that my way could be dangerous and that I should use memmove(...) instead. but I am not sure why my code could be 'dangerous'...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
7
by: Sascha Herpers | last post by:
Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two...
22
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
6
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...
31
by: rkk | last post by:
Hi, I've written a small trim function to trim away the whitespaces in a given string. It works well with solaris forte cc compiler, but on mingw/cygwin gcc it isn't. Here is the code: char...
5
by: laurasaur | last post by:
Hiya guys, have read in a file name but its in a weird format, like this filename.date.key i need to trim off .key any ideas? TrimEnd is not filling me with joy. Cheers Laura
3
by: BlackMustard | last post by:
hi all, i am having problems using the Trim() function in a program written in VB6. i'm getting my strings from reading a textfile line by line, but regardless of the trim function a couple of...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.