Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

php - check if a file exists? check the name?

 
   Web Hosting and Web Master Forums (Home) -> Webmaster RSS
Next:  Mirror Sites Required Across Europe  
Author Message
user148

External


Since: Jul 20, 2003
Posts: 6



(Msg. 1) Posted: Thu Aug 07, 2003 9:20 am
Post subject: php - check if a file exists? check the name?
Archived from groups: alt>www>webmaster (more info?)

Hey all,
I'm having a bit of a problem with my website so I was wondering if anyone
would be able to help.

I'll give you a bit of background first. Basically what I am doing is
uploading a certain amount of pictures (amount varies day-to-day) to my
website. The pictures are named in the following format : (date)a(picture
number).jpg so for example, if it was the 22 August 2003 and I had uploaded
4 pictures that day, the pictures would be named:
2003-8-22a1.jpg
2003-8-22a2.jpg
2003-8-22a3.jpg
2003-8-22a4.jpg

Now what I am having trouble with is that I want a script in which it
automatically finds the (picture number) part of the file name for the
pictures that were uploaded that particular day, which in the above example
would be 1,2,3,4. This is because on the site, a "next pic" link comes up if
there is another pictures available and disappears when on the last picture.
I need the script to find out picture number part so it can find the maximum
picture number (4 in the above example) and then show "next pic" until it
gets to picture 2003-8-22a(maximum picture number).jpg or rather
2003-8-22a4.jpg which is the last picture for that day so "next pic"
disappears.

This may seem hard to understand so please ask if you want me to write it
again.

Thanks for the help,
- Jake

 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
ngx

External


Since: Jun 28, 2003
Posts: 578



(Msg. 2) Posted: Thu Aug 07, 2003 10:50 am
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

JakeC" <"SPAM-FlLTER wrote:
 > ...
 > Basically what I am doing is
 > uploading a certain amount of pictures (amount varies day-to-day) to
 > my website.
 > ...
 > I need the script to find out picture
 > number part so it can find the maximum picture number (4 in the above
 > example) and then show "next pic" until it gets to picture
 > 2003-8-22a(maximum picture number).jpg or rather 2003-8-22a4.jpg
 > which is the last picture for that day so "next pic" disappears.

Load the file names into an array (any construct - any language) and count
them; then you wont care how they are named.

--
William Tasso - <a style='text-decoration: underline;' href="http://WilliamTasso.com" target="_blank">http://WilliamTasso.com</a><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
user148

External


Since: Jul 20, 2003
Posts: 6



(Msg. 3) Posted: Thu Aug 07, 2003 10:50 am
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"William Tasso" <ngx.DeleteThis@tbdata.com> wrote in message
news:bgssct$rhv42$1@ID-139074.news.uni-berlin.de...
 > JakeC" <"SPAM-FlLTER wrote:
  > > ...
  > > Basically what I am doing is
  > > uploading a certain amount of pictures (amount varies day-to-day) to
  > > my website.
  > > ...
  > > I need the script to find out picture
  > > number part so it can find the maximum picture number (4 in the above
  > > example) and then show "next pic" until it gets to picture
  > > 2003-8-22a(maximum picture number).jpg or rather 2003-8-22a4.jpg
  > > which is the last picture for that day so "next pic" disappears.
 >
 > Load the file names into an array (any construct - any language) and count
 > them; then you wont care how they are named.
 >
 > --
<font color=purple> > William Tasso - <a style='text-decoration: underline;' href="http://WilliamTasso.com</font" target="_blank">http://WilliamTasso.com</font</a>>
 >

Yes I could do that but I want this to be completely handled by the system
since if I need to I could just look at the file names and find the largest
number which would be the amount of pictures and then manually enter that in
to the database using a form. The reason is that I will most likely
eventually have somebody else taking and uploading the photos and I do not
want to have to be looking through the files to find that particular days
photos and load them into an array or find the amount of photos. I could
also end up having over a hundred photos a day and that would take quite
some time to load all those files into an array or find the amount of
photos.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
user104

External


Since: Jun 28, 2003
Posts: 1662



(Msg. 4) Posted: Thu Aug 07, 2003 1:23 pm
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"JakeC" <"SPAM-FlLTER"jake-c@bigpond.net.au> wrote in message
news:QcmYa.18722$bo1.2784@news-server.bigpond.net.au...
 > Hey all,
 > I'm having a bit of a problem with my website so I was wondering if anyone
 > would be able to help.
 >
 > I'll give you a bit of background first. Basically what I am doing is
 > uploading a certain amount of pictures (amount varies day-to-day) to my
 > website. The pictures are named in the following format : (date)a(picture
 > number).jpg so for example, if it was the 22 August 2003 and I had
uploaded
 > 4 pictures that day, the pictures would be named:
 > 2003-8-22a1.jpg
 > 2003-8-22a2.jpg
 > 2003-8-22a3.jpg
 > 2003-8-22a4.jpg
 >
 > Now what I am having trouble with is that I want a script in which it
 > automatically finds the (picture number) part of the file name for the
 > pictures that were uploaded that particular day, which in the above
example
 > would be 1,2,3,4. This is because on the site, a "next pic" link comes up
if
 > there is another pictures available and disappears when on the last
picture.
 > I need the script to find out picture number part so it can find the
maximum
 > picture number (4 in the above example) and then show "next pic" until it
 > gets to picture 2003-8-22a(maximum picture number).jpg or rather
 > 2003-8-22a4.jpg which is the last picture for that day so "next pic"
 > disappears.
 >
 > This may seem hard to understand so please ask if you want me to write it
 > again.

You say you want a script to make the "next pic" link disappear, yet you
also say the site is presently doing this?? Is that part working or not?

There are 101 ways to achieve this, but if I was going to Dublin, I probably
wouldn't start from here.

You say you "want a script", are you looking for something ready made? I
imagine it would be very difficult to find something off-the-shelf that
would suit your exact requirements.

Are you writing the php yourself?

Since you are using a database, each pic will have its own record (row) you
can count the rows.
--
Charles Sweeney
<a style='text-decoration: underline;' href="http://www.CharlesSweeney.com" target="_blank">www.CharlesSweeney.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
no_user

External


Since: Jul 03, 2003
Posts: 98



(Msg. 5) Posted: Thu Aug 07, 2003 1:32 pm
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <QcmYa.18722$bo1.2784@news-server.bigpond.net.au>, JakeC wrote:
 > Hey all,
 > I'm having a bit of a problem with my website so I was wondering if anyone
 > would be able to help.
 >
 > I'll give you a bit of background first. Basically what I am doing is
 > uploading a certain amount of pictures (amount varies day-to-day) to my
 > website. The pictures are named in the following format : (date)a(picture
 > number).jpg so for example, if it was the 22 August 2003 and I had uploaded
 > 4 pictures that day, the pictures would be named:
 > 2003-8-22a1.jpg
 > 2003-8-22a2.jpg
 > 2003-8-22a3.jpg
 > 2003-8-22a4.jpg
 >
 > Now what I am having trouble with is that I want a script in which it
 > automatically finds the (picture number) part of the file name for the
 > pictures that were uploaded that particular day, which in the above example
 > would be 1,2,3,4. This is because on the site, a "next pic" link comes up if
 > there is another pictures available and disappears when on the last picture.
 > I need the script to find out picture number part so it can find the maximum
 > picture number (4 in the above example) and then show "next pic" until it
 > gets to picture 2003-8-22a(maximum picture number).jpg or rather
 > 2003-8-22a4.jpg which is the last picture for that day so "next pic"
 > disappears.
 >
 > This may seem hard to understand so please ask if you want me to write it
 > again.
 >
 > Thanks for the help,
 > - Jake

Is this what you want.....

Use the directory function in php to read the files names into an array then
sort...

Then if you looking for pics from Aug 22nd 2003, check each element in the
array :

$j=0;

for ($i=0; $i < count($dir_array); $i++){

if (substr($dir_array[$i],0,9)==$dateformat)
$display_array[$j++]=$dir_array[$i];

}

$display_count=count($display_array);

then format and display the $display_array

kb<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
user148

External


Since: Jul 20, 2003
Posts: 6



(Msg. 6) Posted: Thu Aug 07, 2003 1:55 pm
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Charles Sweeney" <me.RemoveThis@charlessweeney.com> wrote in message
news:bgt5q4$sece6$1@ID-162618.news.uni-berlin.de...

  > > This may seem hard to understand so please ask if you want me to write
it
  > > again.
 >
 > You say you want a script to make the "next pic" link disappear, yet you
 > also say the site is presently doing this?? Is that part working or not?
 >
 > There are 101 ways to achieve this, but if I was going to Dublin, I
probably
 > wouldn't start from here.
 >
 > You say you "want a script", are you looking for something ready made? I
 > imagine it would be very difficult to find something off-the-shelf that
 > would suit your exact requirements.
 >
 > Are you writing the php yourself?
 >
 > Since you are using a database, each pic will have its own record (row)
you
 > can count the rows.
 > --
 > Charles Sweeney
<font color=purple> > <a style='text-decoration: underline;' href="http://www.CharlesSweeney.com</font" target="_blank">www.CharlesSweeney.com</font</a>>





OK. I was in a rush when writing this so I expected it to be a bit hard to
understand. I'll try and explain it again.

A friend and I are currently developing a website in which he does the
graphic design and I do the programming (I have created websites using html,
javascript, css and ssi however this is my first attempt at using php and
mysql). The website is a daily surf report. It currently is 100% in php
however I have already setup a database in mysql and created a webpage so I
can add new data to it. I will add the database to it after I get the basics
of what I want to do down first.

What I want is the following. Once the pictures for the report are uploaded
to the server, Mysql or PHP then automatically finds how many pictures for
that day are on the server and saves this value to the database. That is
what I need help with. I have already made the script for making "next set"
disappear when it gets to the last set.

Hope you can understand Smile
- Jake<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
blogan

External


Since: Jun 30, 2003
Posts: 285



(Msg. 7) Posted: Fri Aug 08, 2003 1:56 am
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"JakeC" <"SPAM-FlLTER"jake-c@bigpond.net.au> wrote in message
news:AOmYa.18771$bo1.107@news-server.bigpond.net.au...
 >
 > "William Tasso" <ngx.TakeThisOut@tbdata.com> wrote in message
 > news:bgssct$rhv42$1@ID-139074.news.uni-berlin.de...
  > > JakeC" <"SPAM-FlLTER wrote:
   > > > ...
   > > > Basically what I am doing is
   > > > uploading a certain amount of pictures (amount varies day-to-day) to
   > > > my website.
   > > > ...
   > > > I need the script to find out picture
   > > > number part so it can find the maximum picture number (4 in the above
   > > > example) and then show "next pic" until it gets to picture
   > > > 2003-8-22a(maximum picture number).jpg or rather 2003-8-22a4.jpg
   > > > which is the last picture for that day so "next pic" disappears.
  > >
  > > Load the file names into an array (any construct - any language) and
count
  > > them; then you wont care how they are named.
  > >
  > > --
<font color=green>  > > William Tasso - <a style='text-decoration: underline;' href="http://WilliamTasso.com</font" target="_blank">http://WilliamTasso.com</font</a>>
  > >
 >
 > Yes I could do that but I want this to be completely handled by the system
 > since if I need to I could just look at the file names and find the
largest
 > number which would be the amount of pictures and then manually enter that
in
 > to the database using a form. The reason is that I will most likely
 > eventually have somebody else taking and uploading the photos and I do not
 > want to have to be looking through the files to find that particular days
 > photos and load them into an array or find the amount of photos. I could
 > also end up having over a hundred photos a day and that would take quite
 > some time to load all those files into an array or find the amount of
 > photos.
 >
Are you using (able to ) a DB? which??

If you are using MySql with PhP I can give you an answer:-)<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
user148

External


Since: Jul 20, 2003
Posts: 6



(Msg. 8) Posted: Fri Aug 08, 2003 11:33 pm
Post subject: Re: php - check if a file exists? check the name? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

 >
 > Is this what you want.....
 >
 > Use the directory function in php to read the files names into an array
then
 > sort...

Sort of. I want php to read the files names FOR A PARTICULAR DAY into an
array then sort AND COUNT them.

 >
 > Then if you looking for pics from Aug 22nd 2003, check each element in the
 > array :
 >
 > $j=0;
 >
 > for ($i=0; $i < count($dir_array); $i++){
 >
 > if (substr($dir_array[$i],0,9)==$dateformat)
 > $display_array[$j++]=$dir_array[$i];
 >
 > }
 >
 > $display_count=count($display_array);
 >
 > then format and display the $display_array
 >

I tried this code and came up with the following errors:
PHP Notice: Undefined variable: dir_array in C:\httpd\HTDOCS\index.php on
line 29
PHP Notice: Undefined variable: display_array in C:\httpd\HTDOCS\index.php
on line 36

Thanks for the help though see above and everyone else who replied to this
post. It is greatly appreciated!<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: php - check if a file exists? check the name? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Check This Out! - Dear Entrepreneur, There are five and a half million small businesses in the U.S. Fewer than half have functional web sites. Learn how AITs exclusive I-MHIP solution gives you the tools to break into this huge market by becoming an independent Internet...

site check plz - Just gave a facelift to an old site and would like some feedback. Especially curious about page load times on dialup. www.rigrunnersfishing.com The owner really likes it, although he accused me of being stoned when I made it for some reason......ha ha ...

site check please - Could you guys give a new site I've just developed the once over please. The url is www.theenvironmentsite.org Thanks for your help. Adi

Check out this affordable Web Host - Looking for some low-cost and reliable web hosting? Then check out http://www.HostsLTD.com

site check (Namestead layout) - Please be so kind as to give comments and feedback on a layout we are considering for Namestead: http://www.namestead.com/projects/layout/030712.jpg This layout is for http://www.namestead.com/ which is a domain name monitoring service (Namestead..
   Web Hosting and Web Master Forums (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]