php-general Digest 25 Nov 2007 23:42:03 -0000 Issue 5147
Topics (messages 265003 through 265010):
Re: Adv. photo scripts
265003 by: Robert Cummings
265004 by: Casey
265007 by: PHP-General
Re: URL Parsing...
265005 by: Richard Heyes
265006 by: Jochem Maas
265008 by: Richard Heyes
265009 by: Jochem Maas
Re: Performance question for table updating
265010 by: Chris
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Sun, 2007-11-25 at 01:59 -0500, PHP-General wrote:
> Not sure if I'm at the right place but here goes....
>
> I'm trying to create a script that will let users upload photos. It is a
> high traffic site and I've been told its best to create a function that will
> generate a unique filename for a temp. file, put the temp file elsewhere on
> the server, and then use an (unlink???) function to delete the temp. file
> after it gets written to the d-base.
>
> How would I do that?
PHP already does ALL that for you. You just need to save the file to
your DB. See the $_FILES global array for uploaded files.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--- End Message ---
--- Begin Message ---
On Nov 24, 2007 11:16 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Sun, 2007-11-25 at 01:59 -0500, PHP-General wrote:
> > Not sure if I'm at the right place but here goes....
> >
> > I'm trying to create a script that will let users upload photos. It is a
> > high traffic site and I've been told its best to create a function that will
> > generate a unique filename for a temp. file, put the temp file elsewhere on
> > the server, and then use an (unlink???) function to delete the temp. file
> > after it gets written to the d-base.
> >
> > How would I do that?
>
> PHP already does ALL that for you. You just need to save the file to
> your DB. See the $_FILES global array for uploaded files.
>
> Cheers,
> Rob.
> --
> ...........................................................
> SwarmBuy.com - http://www.swarmbuy.com
>
> Leveraging the buying power of the masses!
> ...........................................................
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
See this for examples:
http://us.php.net/features.file-upload
-Casey
--- End Message ---
--- Begin Message ---
Thanks for all the replys. I should have warned you in advance that I am new
;)
"Casey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On Nov 24, 2007 11:16 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
On Sun, 2007-11-25 at 01:59 -0500, PHP-General wrote:
> Not sure if I'm at the right place but here goes....
>
> I'm trying to create a script that will let users upload photos. It is
> a
> high traffic site and I've been told its best to create a function that
> will
> generate a unique filename for a temp. file, put the temp file
> elsewhere on
> the server, and then use an (unlink???) function to delete the temp.
> file
> after it gets written to the d-base.
>
> How would I do that?
PHP already does ALL that for you. You just need to save the file to
your DB. See the $_FILES global array for uploaded files.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
See this for examples:
http://us.php.net/features.file-upload
-Casey
--- End Message ---
--- Begin Message ---
one of these should give you something to go on:
echo preg_replace('\.cfm$', '-meta.cfm', parse_url($_SERVER['REQUEST_URI'],
PHP_URL_PATH)), "\n";
echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['PATH_TRANSLATED']), "\n";
echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['SCRIPT_FILENAME']), "\n";
Anything would be helpful. :)
You don't need the overhead of PCRE, though it is the fastest to write,
since it's already above for you...
Or parse_url(). basename(__FILE__) will get you the filename.
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
>> one of these should give you something to go on:
>>
>> echo preg_replace('\.cfm$', '-meta.cfm',
>> parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), "\n";
>> echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['PATH_TRANSLATED']),
>> "\n";
>> echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['SCRIPT_FILENAME']),
>> "\n";
>>
>>> Anything would be helpful. :)
>
> You don't need the overhead of PCRE, though it is the fastest to write,
> since it's already above for you...
well if you take a string (filename) and wish to change the end of it somone
then I don't think str_replace() is the correct function. what's to say a script
doesn't exist called 'my.cfm.php'?
>
> Or parse_url(). basename(__FILE__) will get you the filename.
ah yes basename() - I forgot to put use that in the examples, good catch.
>
--- End Message ---
--- Begin Message ---
well if you take a string (filename) and wish to change the end of it somone
then I don't think str_replace() is the correct function. what's to say a script
doesn't exist called 'my.cfm.php'?
How does this:
/\.cfm$/
take into account that?
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
>> well if you take a string (filename) and wish to change the end of it
>> somone
>> then I don't think str_replace() is the correct function. what's to
>> say a script
>> doesn't exist called 'my.cfm.php'?
>
> How does this:
>
> /\.cfm$/
>
> take into account that?
WTF
>
--- End Message ---
--- Begin Message ---
Eventually, I wind up with a query similar to:
UPDATE table_01 SET field_a = 'New value here', updated=CURDATE() WHERE
primary_key=12345
Even though you've solved it one way to work out the problem here would
be to change it to a select query (unfortunately mysql can't explain
insert/update/delete statements - which would make it a lot easier).
ie change it to
select 1 from table where primary_key=12345;
If that's slow, then you're missing an index on primary_key.
If that's fast.. err, you're back to square one :/ or maybe you have too
many indexes (which means the update process is spending all of it's
time updating the fields & indexes).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---