php-general Digest 10 Jul 2013 11:15:30 -0000 Issue 8290

2013-07-10 Thread php-general-digest-help

php-general Digest 10 Jul 2013 11:15:30 - Issue 8290

Topics (messages 321584 through 321586):

Re: Making a Timeout Expiration Length to Session Variables
321584 by: Karim Geiger

Re: htaccess
321585 by: Tim Streater

syntax question
321586 by: Jim Giner

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


--
---BeginMessage---
Hi,

On 07/08/2013 05:10 AM, dealTek wrote:
 Hi all,
 
 I would like to make a timeout length to session variables, so that if a user 
 didn't use the browser page for let's say 5 minutes - the session variables 
 would expire and the user would need to login again.
 
 
 Q: What's the best way to implement this functionality?

You can either use cookies or do something like that:
http://stackoverflow.com/questions/3068744/php-session-timeout

In your case is would be
if ($_SESSION['timeout'] + 5 * 60  time()) {
// session timed out
} else {
// session ok
}

Karim

-- 
Karim Geiger
Auszubildender Fachinformatiker AE

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537



signature.asc
Description: OpenPGP digital signature
---End Message---
---BeginMessage---
On 07 Jul 2013 at 21:22, Tedd Sperling t...@sperling.com wrote: 

 Confirmed. Those two lines cause the problem.

 However, commenting out those lines causes other problems.

 Are there similar statements to these:

   AddType application/x-httpd-php .php .htm .html

This one tells apache to recognise .php, .htm, and .html as suffixes of files 
that need to be sent to PHP. You probably don't want to remove that [1].

   AddHandler x-httpd-php5-cgi .php .htm .html

Dunno what this one does.

[1] But, having said that, realise that *all* files with those suffixes will be 
sent to PHP by apache, whether they contain any PHP code or not. Is that what 
you want? If I have an html file that contains some PHP code, I tend to use 
.phtml as suffix and so my AddType looks like:

 AddType application/x-httpd-php .php .phtml

--
Cheers  --  Tim
---End Message---
---BeginMessage---
Can someone tell me what this syntax is?  I looked around but don't see 
any mention of it.


while(condition) : (statement);



---End Message---


[PHP] syntax question

2013-07-10 Thread Jim Giner
Can someone tell me what this syntax is?  I looked around but don't see 
any mention of it.


while(condition) : (statement);




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] syntax question

2013-07-10 Thread Přemysl Fiala

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);






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] syntax question

2013-07-10 Thread Jim Giner

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
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


[PHP] Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
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/


[PHP] Re: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Jim Giner

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?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Jim Giner

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 trthProduct/ththAmount/th/tr;

// loop thru each item found
while ($results = $qrslts-fetch(PDO::FETCH_ASSOC))
{
   echo 
trtd.$results['product_name']./tdtd.$results['product_amt']./td/tr;

}

// finish the table html
echo /table;




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
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 trthProduct/thth**Amount/th/tr;

 // loop thru each item found
 while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC))
 {
echo trtd.$results['product_**name']./tdtd.$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


Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get incorrect direction...

2013-07-10 Thread Jim Giner

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 trthProduct/thth**Amount/th/tr;

// loop thru each item found
while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC))
{
echo trtd.$results['product_**name']./tdtd.$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!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Lester Caine

Karl-Arne Gjersøyen wrote:

// start the table


$total = 0;


echo table border=1;
echo trthProduct/thth**Amount/th/tr;

// loop thru each item found
while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC))
{
echo trtd.$results['product_**name']./tdtd.$results['**
product_amt']./td/tr;

$total += $results['product_amt']

}



echo trtdTotal:/tdtd.$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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
2013/7/10 Lester Caine les...@lsces.co.uk

 Karl-Arne Gjersøyen wrote:

 // start the table


 $total = 0;

  echo table border=1;
 echo trthProduct/ththAmount/th/tr;

 
 // loop thru each item found
 while ($results = $qrslts-fetch(PDO::FETCH_ASSOC))
 {
 echo trtd.$results['product_name']./tdtd.$results['
 
 product_amt']./td/tr;

 $total += $results['product_amt']

 }
 


 echo trtdTotal:/tdtd.$**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


[PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Ajay Garg
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Query regarding temporarily-uploaded files

2013-07-10 Thread Jim Giner

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.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Matijn Woudt
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


Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Ajay Garg
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


Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Jim Giner

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.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Ajay Garg
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.comwrote:

 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


Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Jim Giner

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.comwrote:


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.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Anthony Wlodarski
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


Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Bastien


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 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php