php-general Digest 11 Jul 2013 14:35:03 -0000 Issue 8291
Topics (messages 321587 through 321606):
Re: syntax question
321587 by: Pøemysl Fiala
321588 by: Jim Giner
Hmmm.. I think I need your advice here to get in correct direction...
321589 by: Karl-Arne Gjersøyen
321590 by: Karl-Arne Gjersøyen
321591 by: Jim Giner
321592 by: Jim Giner
321593 by: Karl-Arne Gjersøyen
321594 by: Jim Giner
321595 by: Lester Caine
321596 by: Karl-Arne Gjersøyen
Query regarding temporarily-uploaded files
321597 by: Ajay Garg
321598 by: Jim Giner
321599 by: Matijn Woudt
321600 by: Ajay Garg
321601 by: Jim Giner
321602 by: Anthony Wlodarski
321603 by: Ajay Garg
321604 by: Jim Giner
321605 by: Bastien
Re: strlen ?
321606 by: Caio Tavares
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hello,
is an alternative syntax.
http://php.net/manual/en/control-structures.alternative-syntax.php
Premek.
On Wed, 10 Jul 2013 13:15:22 +0200, Jim Giner
<jim.gi...@albanyhandball.com> wrote:
Can someone tell me what this syntax is? I looked around but don't see
any mention of it.
while(condition) : (statement);
--- End Message ---
--- Begin Message ---
Thanks!
--- End Message ---
--- Begin Message ---
I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.
I like to register new products and the amount in number (for example 4)
and weight in kg.
I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10
--- End Message ---
--- Begin Message ---
Sorry, the first mail in this subject run out for me. This is an updated
one.
I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.
I like to register new products and the amount in number (for example 4)
and weight in kg.
I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10 - Weight 10kg
Then I like to 4+10 = 14
and 200+10 = 210.
It shall looks like this:
======================================
Dynamite | 4 | 200
Lunt | 10 | 10
------------------------------------------------------------------
TOTAL | 14 | 210
It is easy to register this product by product on their own row.
but in what way can I multiply them? ned products be stored in arrays?
I think it will be similar to shopping cart in online store but i have no
clue about how to do this.
If you have links to pages were i can learn am i Happy for it. If you can
help me here is even better.
Thanks for your time and effort to learn me programming.
Karl
--
Hjemmeside: http://www.karl-arne.name/
--- End Message ---
--- Begin Message ---
On 7/10/2013 8:30 AM, Karl-Arne Gjersøyen wrote:
I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.
I like to register new products and the amount in number (for example 4)
and weight in kg.
I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10
Show us your code?
--- End Message ---
--- Begin Message ---
On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote:
Sorry, the first mail in this subject run out for me. This is an updated
one.
I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.
I like to register new products and the amount in number (for example 4)
and weight in kg.
I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10 - Weight 10kg
Then I like to 4+10 = 14
and 200+10 = 210.
It shall looks like this:
======================================
Dynamite | 4 | 200
Lunt | 10 | 10
------------------------------------------------------------------
TOTAL | 14 | 210
It is easy to register this product by product on their own row.
but in what way can I multiply them? ned products be stored in arrays?
I think it will be similar to shopping cart in online store but i have no
clue about how to do this.
If you have links to pages were i can learn am i Happy for it. If you can
help me here is even better.
Thanks for your time and effort to learn me programming.
Karl
Ahhh.....
So - you should run a query that selects the products and information
that you want. Then you start by creating an html table header and then
loop through your query results and echo a table row for each result row.
// start the table
echo "<table border=1>";
echo "<tr><th>Product</th><th>Amount</th></tr>";
// loop thru each item found
while ($results = $qrslts->fetch(PDO::FETCH_ASSOC))
{
echo
"<tr><td>".$results['product_name']."</td><td>".$results['product_amt']."</td></tr>";
}
// finish the table html
echo "</table";
--- End Message ---
--- Begin Message ---
2013/7/10 Jim Giner <jim.gi...@albanyhandball.com>
> On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote:
>
>> Sorry, the first mail in this subject run out for me. This is an updated
>> one.
>>
>>
>>
>> I am almost ready with my learning project in PHP/MySQL.
>> I can register new product in stock.
>> Add and increase the number and weight.
>> I can move products between different storehouses
>> I can also transfer products from store and onto a "truck document" but
>> that's it and here I need some advice.
>>
>> I like to register new products and the amount in number (for example 4)
>> and weight in kg.
>>
>> I like to write it in this way:
>> Dynamite - package 4 - Weight 200 kg
>> Lunt - Package 10 - Weight 10kg
>>
>> Then I like to 4+10 = 14
>> and 200+10 = 210.
>>
>> It shall looks like this:
>> ==============================**========
>> Dynamite | 4 | 200
>> Lunt | 10 | 10
>> ------------------------------**------------------------------**------
>> TOTAL | 14 | 210
>>
>> It is easy to register this product by product on their own row.
>> but in what way can I multiply them? ned products be stored in arrays?
>> I think it will be similar to shopping cart in online store but i have no
>> clue about how to do this.
>> If you have links to pages were i can learn am i Happy for it. If you can
>> help me here is even better.
>>
>> Thanks for your time and effort to learn me programming.
>>
>> Karl
>>
>>
>>
>>
>> Ahhh.....
>
> So - you should run a query that selects the products and information that
> you want. Then you start by creating an html table header and then loop
> through your query results and echo a table row for each result row.
>
> // start the table
> echo "<table border=1>";
> echo "<tr><th>Product</th><th>**Amount</th></tr>";
>
> // loop thru each item found
> while ($results = $qrslts->fetch(PDO::FETCH_**ASSOC))
> {
> echo "<tr><td>".$results['product_**name']."</td><td>".$results['**
> product_amt']."</td></tr>";
> }
>
> // finish the table html
> echo "</table";
Yes that part is OK. I do have problem to add total weight and package at
bottom of the table like this:
Product_one 40kg
Product_two 60kg
-------------------------
Total: 100kg
===============
Because sometimes it is only a few products and other times many products.
I then need to summing them at bottom. One timer only 3 rows, other times
20 rows. The program need a way to add every singel product and see if it's
a few or many,
Karl
--- End Message ---
--- Begin Message ---
On 7/10/2013 9:07 AM, Karl-Arne Gjersøyen wrote:
2013/7/10 Jim Giner <jim.gi...@albanyhandball.com>
On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote:
Sorry, the first mail in this subject run out for me. This is an updated
one.
I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.
I like to register new products and the amount in number (for example 4)
and weight in kg.
I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10 - Weight 10kg
Then I like to 4+10 = 14
and 200+10 = 210.
It shall looks like this:
==============================**========
Dynamite | 4 | 200
Lunt | 10 | 10
------------------------------**------------------------------**------
TOTAL | 14 | 210
It is easy to register this product by product on their own row.
but in what way can I multiply them? ned products be stored in arrays?
I think it will be similar to shopping cart in online store but i have no
clue about how to do this.
If you have links to pages were i can learn am i Happy for it. If you can
help me here is even better.
Thanks for your time and effort to learn me programming.
Karl
Ahhh.....
So - you should run a query that selects the products and information that
you want. Then you start by creating an html table header and then loop
through your query results and echo a table row for each result row.
// start the table
echo "<table border=1>";
echo "<tr><th>Product</th><th>**Amount</th></tr>";
// loop thru each item found
while ($results = $qrslts->fetch(PDO::FETCH_**ASSOC))
{
echo "<tr><td>".$results['product_**name']."</td><td>".$results['**
product_amt']."</td></tr>";
}
// finish the table html
echo "</table";
Yes that part is OK. I do have problem to add total weight and package at
bottom of the table like this:
Product_one 40kg
Product_two 60kg
-------------------------
Total: 100kg
===============
Because sometimes it is only a few products and other times many products.
I then need to summing them at bottom. One timer only 3 rows, other times
20 rows. The program need a way to add every singel product and see if it's
a few or many,
Karl
So - as you loop thru the results, accumulate your totals and then at
the end before you close the table generate one last row with those
amounts in it. Simple!
--- End Message ---
--- Begin Message ---
Karl-Arne Gjersøyen wrote:
// start the table
$total = 0;
>echo "<table border=1>";
>echo "<tr><th>Product</th><th>**Amount</th></tr>";
>
>// loop thru each item found
>while ($results = $qrslts->fetch(PDO::FETCH_**ASSOC))
>{
> echo "<tr><td>".$results['product_**name']."</td><td>".$results['**
>product_amt']."</td></tr>";
$total += $results['product_amt']
>}
>
echo "<tr><td>Total:</td><td>".$total."</td></tr>";
>// finish the table html
>echo "</table";
Yes that part is OK. I do have problem to add total weight and package at
bottom of the table like this:
Product_one 40kg
Product_two 60kg
-------------------------
Total: 100kg
===============
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
2013/7/10 Lester Caine <les...@lsces.co.uk>
> Karl-Arne Gjersøyen wrote:
>
>> // start the table
>>>
>>
> $total = 0;
>
> >echo "<table border=1>";
>>> >echo "<tr><th>Product</th><th>****Amount</th></tr>";
>>>
>>> >
>>> >// loop thru each item found
>>> >while ($results = $qrslts->fetch(PDO::FETCH_****ASSOC))
>>> >{
>>> > echo "<tr><td>".$results['product_****name']."</td><td>".$results['
>>> ****
>>> >product_amt']."</td></tr>";
>>>
>> $total += $results['product_amt']
>
>> >}
>>> >
>>>
>>
> echo "<tr><td>Total:</td><td>".$**total."</td></tr>";
>
>
> >// finish the table html
>>> >echo "</table";
>>>
>>
>> Yes that part is OK. I do have problem to add total weight and package at
>> bottom of the table like this:
>>
>> Product_one 40kg
>> Product_two 60kg
>> -------------------------
>> Total: 100kg
>> ===============
>>
>
>
Thank you very Much, Both of you Jim and Lester!
You are amazing, folks!
Karl
--- End Message ---
--- Begin Message ---
Hi all.
I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.
Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
"finally" (that is, after being copied from the temporary location,
via "move_uploaded_file")
Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous "Hello World" examples
available :)
Now, I am facing the following use-case ::
1)
User 1 starts uploading a large file, say "big_file.avi".
2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name "big_file.avi".
In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?
( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).
Any way the issue may be solved?
I will be grateful for any pointers :)
Regards,
Ajay
--- End Message ---
--- Begin Message ---
On 7/10/2013 1:21 PM, Ajay Garg wrote:
Hi all.
I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.
Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
"finally" (that is, after being copied from the temporary location,
via "move_uploaded_file")
Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous "Hello World" examples
available :)
Now, I am facing the following use-case ::
1)
User 1 starts uploading a large file, say "big_file.avi".
2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name "big_file.avi".
In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?
( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).
Any way the issue may be solved?
I will be grateful for any pointers :)
Regards,
Ajay
The problem is not of PHP's making. It is something that you have to
program around. Is the user determining the filename to be used? If
so, then you need to check for that name before doing you "move". If
it's a duple, then create a temporary name in your final place, hide it
in the user's page and send it back to him with a message to change his
name.
If the user is NOT determining the name, then your normal process would
be to pick an unused name I presume and send That back to the user
anyway, so problem never happens.
--- End Message ---
--- Begin Message ---
On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
> Hi all.
>
> I have a requirement, wherein I need to allow vanilla uploads of files
> to a HTTPD server.
>
> Any client can upload any number of files (one at a time).
> Also, there is just one directory, where the files get stored
> "finally" (that is, after being copied from the temporary location,
> via "move_uploaded_file")
>
> Also, I have been able to get the simple file uploading running via
> PHP, by picking up one of the numerous "Hello World" examples
> available :)
>
>
>
> Now, I am facing the following use-case ::
>
> 1)
> User 1 starts uploading a large file, say "big_file.avi".
>
> 2)
> Meanwhile, user 2 also starts uploading a (different) file, but with
> the same name "big_file.avi".
>
>
> In an ideal scenario, user 2 should be prompted with a message, that a
> file of the same name is already being uploaded by someone else
> somewhere.
> Is there a way to do this?
>
> ( Note that, had the user 2 started uploading AFTER user 1 had
> finished with the upload, we could probably modify the PHP-script at
> the sever-side, to let user-2 know that a file of the same name
> already exits. But I am failing to find a solution, when the user 2
> starts the upload WHILE the large file of user 1 is in the process of
> completing uploading).
>
>
> Any way the issue may be solved?
>
> I will be grateful for any pointers :)
>
>
>
> Regards,
> Ajay
>
>
Hi,
This is not possible with PHP, PHP will not know about the file until the
upload is completed. You can use HTML5 or flash(not recommended) for an
alternative way of uploading, and then you can check the file name in
advance.
- Matijn
--- End Message ---
--- Begin Message ---
Thanks Jim and Matijn for the quick replies.
I will try to have a workaround.
On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt <tijn...@gmail.com> wrote:
>
>
>
> On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
>
>> Hi all.
>>
>> I have a requirement, wherein I need to allow vanilla uploads of files
>> to a HTTPD server.
>>
>> Any client can upload any number of files (one at a time).
>> Also, there is just one directory, where the files get stored
>> "finally" (that is, after being copied from the temporary location,
>> via "move_uploaded_file")
>>
>> Also, I have been able to get the simple file uploading running via
>> PHP, by picking up one of the numerous "Hello World" examples
>> available :)
>>
>>
>>
>> Now, I am facing the following use-case ::
>>
>> 1)
>> User 1 starts uploading a large file, say "big_file.avi".
>>
>> 2)
>> Meanwhile, user 2 also starts uploading a (different) file, but with
>> the same name "big_file.avi".
>>
>>
>> In an ideal scenario, user 2 should be prompted with a message, that a
>> file of the same name is already being uploaded by someone else
>> somewhere.
>> Is there a way to do this?
>>
>> ( Note that, had the user 2 started uploading AFTER user 1 had
>> finished with the upload, we could probably modify the PHP-script at
>> the sever-side, to let user-2 know that a file of the same name
>> already exits. But I am failing to find a solution, when the user 2
>> starts the upload WHILE the large file of user 1 is in the process of
>> completing uploading).
>>
>>
>> Any way the issue may be solved?
>>
>> I will be grateful for any pointers :)
>>
>>
>>
>> Regards,
>> Ajay
>>
>>
>
> Hi,
>
> This is not possible with PHP, PHP will not know about the file until the
> upload is completed. You can use HTML5 or flash(not recommended) for an
> alternative way of uploading, and then you can check the file name in
> advance.
>
> - Matijn
>
--
Regards,
Ajay
--- End Message ---
--- Begin Message ---
On 7/10/2013 2:15 PM, Ajay Garg wrote:
Thanks Jim and Matijn for the quick replies.
I will try to have a workaround.
On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt <tijn...@gmail.com> wrote:
On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
Hi all.
I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.
Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
"finally" (that is, after being copied from the temporary location,
via "move_uploaded_file")
Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous "Hello World" examples
available :)
Now, I am facing the following use-case ::
1)
User 1 starts uploading a large file, say "big_file.avi".
2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name "big_file.avi".
In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?
( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).
Any way the issue may be solved?
I will be grateful for any pointers :)
Regards,
Ajay
Hi,
This is not possible with PHP, PHP will not know about the file until the
upload is completed. You can use HTML5 or flash(not recommended) for an
alternative way of uploading, and then you can check the file name in
advance.
- Matijn
As Matijn said, you don't know the name until your php processes the
file that has been uploaded alreaday. But my solution will work for you
- you just have to save it under the temp name until the user responds
to your message and request for a new title. You may have to run a
periodic script to clean up any files with your temp names that the user
declined to re-name for you. I'd make up a temp name with some special
prefix so that you can find and delete them.
--- End Message ---
--- Begin Message ---
Is there anything that would prevent you from somehow uniquely knowing who
the user is uploading the file. For example you mentioned "client'. If you
know
who the client is you can append that to the filename or prepend it, for the
destination string (second parameter to the function call). That way it is
unique
to that client.
-Anthony
On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
> Thanks Jim and Matijn for the quick replies.
> I will try to have a workaround.
>
>
>
> On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt <tijn...@gmail.com> wrote:
>
> >
> >
> >
> > On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg <ajaygargn...@gmail.com>
> wrote:
> >
> >> Hi all.
> >>
> >> I have a requirement, wherein I need to allow vanilla uploads of files
> >> to a HTTPD server.
> >>
> >> Any client can upload any number of files (one at a time).
> >> Also, there is just one directory, where the files get stored
> >> "finally" (that is, after being copied from the temporary location,
> >> via "move_uploaded_file")
> >>
> >> Also, I have been able to get the simple file uploading running via
> >> PHP, by picking up one of the numerous "Hello World" examples
> >> available :)
> >>
> >>
> >>
> >> Now, I am facing the following use-case ::
> >>
> >> 1)
> >> User 1 starts uploading a large file, say "big_file.avi".
> >>
> >> 2)
> >> Meanwhile, user 2 also starts uploading a (different) file, but with
> >> the same name "big_file.avi".
> >>
> >>
> >> In an ideal scenario, user 2 should be prompted with a message, that a
> >> file of the same name is already being uploaded by someone else
> >> somewhere.
> >> Is there a way to do this?
> >>
> >> ( Note that, had the user 2 started uploading AFTER user 1 had
> >> finished with the upload, we could probably modify the PHP-script at
> >> the sever-side, to let user-2 know that a file of the same name
> >> already exits. But I am failing to find a solution, when the user 2
> >> starts the upload WHILE the large file of user 1 is in the process of
> >> completing uploading).
> >>
> >>
> >> Any way the issue may be solved?
> >>
> >> I will be grateful for any pointers :)
> >>
> >>
> >>
> >> Regards,
> >> Ajay
> >>
> >>
> >
> > Hi,
> >
> > This is not possible with PHP, PHP will not know about the file until the
> > upload is completed. You can use HTML5 or flash(not recommended) for an
> > alternative way of uploading, and then you can check the file name in
> > advance.
> >
> > - Matijn
> >
>
>
>
> --
> Regards,
> Ajay
>
--
Anthony W.
ant92...@gmail.com
--- End Message ---
--- Begin Message ---
Thanks Jim and Anthony.
Jim,
You are right, your solution is doable.
But one thing I am a little skeptical about, is what would be the
percentage of the people willing to suggest a new name "immediately",
versus the percentage of people who would like to cancel the current
upload, and come back "later" after walking and coming up with a new name.
Anyhow, let me sleep over it :)
Anthony,
your solution is really a special case of Jim's solution :)
Thanks guys for the quick replies; I am obliged, really.
On Thu, Jul 11, 2013 at 12:59 AM, Anthony Wlodarski <ant92...@gmail.com>wrote:
> Is there anything that would prevent you from somehow uniquely knowing who
> the user is uploading the file. For example you mentioned "client'. If
> you know
> who the client is you can append that to the filename or prepend it, for
> the
> destination string (second parameter to the function call). That way it
> is unique
> to that client.
>
> -Anthony
>
>
> On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
>
>> Thanks Jim and Matijn for the quick replies.
>> I will try to have a workaround.
>>
>>
>>
>> On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt <tijn...@gmail.com> wrote:
>>
>> >
>> >
>> >
>> > On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg <ajaygargn...@gmail.com>
>> wrote:
>> >
>> >> Hi all.
>> >>
>> >> I have a requirement, wherein I need to allow vanilla uploads of files
>> >> to a HTTPD server.
>> >>
>> >> Any client can upload any number of files (one at a time).
>> >> Also, there is just one directory, where the files get stored
>> >> "finally" (that is, after being copied from the temporary location,
>> >> via "move_uploaded_file")
>> >>
>> >> Also, I have been able to get the simple file uploading running via
>> >> PHP, by picking up one of the numerous "Hello World" examples
>> >> available :)
>> >>
>> >>
>> >>
>> >> Now, I am facing the following use-case ::
>> >>
>> >> 1)
>> >> User 1 starts uploading a large file, say "big_file.avi".
>> >>
>> >> 2)
>> >> Meanwhile, user 2 also starts uploading a (different) file, but with
>> >> the same name "big_file.avi".
>> >>
>> >>
>> >> In an ideal scenario, user 2 should be prompted with a message, that a
>> >> file of the same name is already being uploaded by someone else
>> >> somewhere.
>> >> Is there a way to do this?
>> >>
>> >> ( Note that, had the user 2 started uploading AFTER user 1 had
>> >> finished with the upload, we could probably modify the PHP-script at
>> >> the sever-side, to let user-2 know that a file of the same name
>> >> already exits. But I am failing to find a solution, when the user 2
>> >> starts the upload WHILE the large file of user 1 is in the process of
>> >> completing uploading).
>> >>
>> >>
>> >> Any way the issue may be solved?
>> >>
>> >> I will be grateful for any pointers :)
>> >>
>> >>
>> >>
>> >> Regards,
>> >> Ajay
>> >>
>> >>
>> >
>> > Hi,
>> >
>> > This is not possible with PHP, PHP will not know about the file until
>> the
>> > upload is completed. You can use HTML5 or flash(not recommended) for an
>> > alternative way of uploading, and then you can check the file name in
>> > advance.
>> >
>> > - Matijn
>> >
>>
>>
>>
>> --
>> Regards,
>> Ajay
>>
>
>
>
> --
> Anthony W.
> ant92...@gmail.com
>
--
Regards,
Ajay
--- End Message ---
--- Begin Message ---
On 7/10/2013 3:37 PM, Ajay Garg wrote:
Thanks Jim and Anthony.
Jim,
You are right, your solution is doable.
But one thing I am a little skeptical about, is what would be the
percentage of the people willing to suggest a new name "immediately",
versus the percentage of people who would like to cancel the current
upload, and come back "later" after walking and coming up with a new name.
Anyhow, let me sleep over it :)
Anthony,
your solution is really a special case of Jim's solution :)
Thanks guys for the quick replies; I am obliged, really.
On Thu, Jul 11, 2013 at 12:59 AM, Anthony Wlodarski <ant92...@gmail.com>wrote:
Is there anything that would prevent you from somehow uniquely knowing who
the user is uploading the file. For example you mentioned "client'. If
you know
who the client is you can append that to the filename or prepend it, for
the
destination string (second parameter to the function call). That way it
is unique
to that client.
-Anthony
On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
Thanks Jim and Matijn for the quick replies.
I will try to have a workaround.
On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt <tijn...@gmail.com> wrote:
On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg <ajaygargn...@gmail.com>
wrote:
Hi all.
I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.
Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
"finally" (that is, after being copied from the temporary location,
via "move_uploaded_file")
Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous "Hello World" examples
available :)
Now, I am facing the following use-case ::
1)
User 1 starts uploading a large file, say "big_file.avi".
2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name "big_file.avi".
In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?
( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).
Any way the issue may be solved?
I will be grateful for any pointers :)
Regards,
Ajay
Hi,
This is not possible with PHP, PHP will not know about the file until
the
upload is completed. You can use HTML5 or flash(not recommended) for an
alternative way of uploading, and then you can check the file name in
advance.
- Matijn
--
Regards,
Ajay
--
Anthony W.
ant92...@gmail.com
That's why I said you would have to do a cleanup periodically. People
who walk away could lose their session perhaps and the page wiht the
hidden temp name buried in it, so they would have to do their upload
from the beginning again. If they didn't lose their session and
therefore that screen, then they could still respond and things would
flow smoothly.
so - who is scanning these files for viruses and what not? It's one
thing to host them but if you are going to let users view them on their
clients you could be spreading things.
--- End Message ---
--- Begin Message ---
Bastien Koert
On 2013-07-10, at 3:29 PM, Anthony Wlodarski <ant92...@gmail.com> wrote:
> Is there anything that would prevent you from somehow uniquely knowing who
> the user is uploading the file. For example you mentioned "client'. If you
> know
> who the client is you can append that to the filename or prepend it, for the
> destination string (second parameter to the function call). That way it is
> unique
> to that client.
>
> -Anthony
Another option is that you name the files yourself. Numerically for example and
then just switch it back to the uploaded file name when either displaying it or
sending it back to the user.
You should also place all files outside the web root so it's harder to execute
bad files. And prolly filter for files types. Allow only images ( png jpg gif )
for example
Bastien
--- End Message ---
--- Begin Message ---
Try with mb_strlen
see
http://www.php.net/manual/en/function.mb-strlen.php
2013/7/5 Jim Giner <jim.gi...@albanyhandball.com>
> Trying to manage line breaks in some output I'm generating and using
> strlen to measure the lengths of the strings I'm printing. Discovered
> something strange (to me!) in that strlen is returning +1 more than it
> should.
>
> The strings are from a query of my database - simple name fields. But
> everyone of them is coming back with a length that is one more than I see.
>
> Ex.
>
> Mike Hall comes back as 10, not 9
> F.B. comes back as 5, not 4.
>
> I've looked at my data and counted the chars - there is no extra space at
> the beginning or end in my table.
>
> Anyone have an explanation?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---