Re: [PHP] Re: Re: File upload in map drive with PHP
On 28 Jan 2012, at 01:41, Michelle Konzack wrote: Merhaba Mehmet YAYLA, Am 2012-01-26 15:10:34, hacktest Du folgendes herunter: I'm using code this bellow. ...with an error! form enctype=multipart/form-data action=upload_file.php?upload=1 method=post input type=hidden name=MAX_FILE_SIZE value=3 / Select image: input name=userfile type=file/ input type=submit value=Upload / You can not use action=upload_file.php?upload=1 together with method=post and you have to use form enctype=multipart/form-data action=upload_file.php method=post input type=hidden name=MAX_FILE_SIZE value=3 / input type=hidden name=upload value=1 / There is nothing stopping you doing this. Mixing GET and POST parameters is perfectly valid and can be incredibly useful. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: ArrayInterator always true
If you enable notices you will see that PHP outputs this : Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid.This line seems to be the problem //Test if next stream is an option for ( $iterator-next(); $iterator-valid(); $iterator-next() ) { . I think that maybe the problem is that you are accessing the array in the second for, PHP detects that when it gets to the first for and it doesn't know if the array is still the same and starts over . Anyway, you are trying to iterate over the array in a pretty strange way :) . My advice is to use $arrayobject-count() to see how many elements you have and then iterate with a for($i=0; $i $arrayobject-count(); $i++) . Also, if you accept only some options than just use getopt function. On Sat, Jan 28, 2012 at 12:10 AM, TCP tgc...@gmail.com wrote: I've got a temporary fix but still the iterator always return true, still hope someone could help me out to point out the problem:) //parseOptions utilitiese by tgckpg function parseOptions ( $argStream, $handler ) { //Chop first useless argument -- argv[0] array_shift ( $argStream ) ; //Initiate ArrayObject for iterator $arrayobject = new ArrayObject ( $argStream ) ; //Initiate iterator for iteration $iterator = $arrayobject-getIterator(); //If options is set first if( $iterator-valid() preg_match ( '/^-\w$/', $iterator-current() ) ) { //iterate through whole argument stream for ( ; $iterator-valid(); $iterator-next() ) { //Check if reached next option if( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //Get current options $currOpt = $opts; //echo $currOpt\n; //Test if next stream is an option for ( $iterator-next(); $iterator-valid(); $iterator-next() ) { if ( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //echo $currOpt $opts\n; $handler($currOpt); $currOpt = $opts; } else break; //var_dump($iterator-valid()); } }//End if //echo $currOpt $opts\n; $handler($currOpt, $opts); //A temporary fix for infinite loop-- if(!$iterator-valid()) break; }// End for //If option is not set first. } else { //Try other approach. }// End if } On Tue, Jan 24, 2012 at 4:18 AM, TCP tgc...@gmail.com wrote: I'm trying to parse an $agrv array that contain options (without square brackets): [-a abc -b bbc bcc -d dbc -e -f] I use ArrayIterator to iterate through the line: - whenever it reach /-\w/, it read through the following qoutes until it reach another /-\w/. The problem is it seems the $iterator-valid() always return TRUE and cause infinte loop. function parseOptions ( $argStream, $handler ) { //Chop first useless argument -- argv[0] array_shift ( $argStream ) ; //Initiate ArrayObject for iterator $arrayobject = new ArrayObject ( $argStream ) ; //Initiate iterator for iteration $iterator = $arrayobject-getIterator(); //If options is set first if( $iterator-valid() preg_match ( '/^-\w$/', $iterator-current() ) ) { //iterate through whole argument stream for ( ; $iterator-valid(); $iterator-next() ) { //Check if reached next option if( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //Get current options $currOpt = $opts; //echo $currOpt\n; //Test if next stream is an option for ($iterator-next(); $iterator-valid(); $iterator-next() ) { if ( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //echo $currOpt $opts\n; //$handler($currOpt, $opts); $currOpt = $opts; } var_dump($iterator-valid()); } }//End if //echo $currOpt $opts\n;
Re: [PHP] Re: ArrayInterator always true
2012/1/28 Mihai Anghel mihaigrim1...@gmail.com If you enable notices you will see that PHP outputs this : Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid.This line seems to be the problem //Test if next stream is an option for ( $iterator-next(); $iterator-valid(); $iterator-next() ) { . I think that maybe the problem is that you are accessing the array in the second for, PHP detects that when it gets to the first for and it doesn't know if the array is still the same and starts over . Anyway, you are trying to iterate over the array in a pretty strange way :) . My advice is to use $arrayobject-count() to see how many elements you have and then iterate with a for($i=0; $i $arrayobject-count(); $i++) . Also, if you accept only some options than just use getopt function. On Sat, Jan 28, 2012 at 12:10 AM, TCP tgc...@gmail.com wrote: I've got a temporary fix but still the iterator always return true, still hope someone could help me out to point out the problem:) //parseOptions utilitiese by tgckpg function parseOptions ( $argStream, $handler ) { //Chop first useless argument -- argv[0] array_shift ( $argStream ) ; //Initiate ArrayObject for iterator $arrayobject = new ArrayObject ( $argStream ) ; //Initiate iterator for iteration $iterator = $arrayobject-getIterator(); //If options is set first if( $iterator-valid() preg_match ( '/^-\w$/', $iterator-current() ) ) { //iterate through whole argument stream for ( ; $iterator-valid(); $iterator-next() ) { //Check if reached next option if( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //Get current options $currOpt = $opts; //echo $currOpt\n; //Test if next stream is an option for ( $iterator-next(); $iterator-valid(); $iterator-next() ) { if ( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //echo $currOpt $opts\n; $handler($currOpt); $currOpt = $opts; } else break; //var_dump($iterator-valid()); } }//End if //echo $currOpt $opts\n; $handler($currOpt, $opts); //A temporary fix for infinite loop-- if(!$iterator-valid()) break; }// End for //If option is not set first. } else { //Try other approach. }// End if } On Tue, Jan 24, 2012 at 4:18 AM, TCP tgc...@gmail.com wrote: I'm trying to parse an $agrv array that contain options (without square brackets): [-a abc -b bbc bcc -d dbc -e -f] I use ArrayIterator to iterate through the line: - whenever it reach /-\w/, it read through the following qoutes until it reach another /-\w/. The problem is it seems the $iterator-valid() always return TRUE and cause infinte loop. function parseOptions ( $argStream, $handler ) { //Chop first useless argument -- argv[0] array_shift ( $argStream ) ; //Initiate ArrayObject for iterator $arrayobject = new ArrayObject ( $argStream ) ; //Initiate iterator for iteration $iterator = $arrayobject-getIterator(); //If options is set first if( $iterator-valid() preg_match ( '/^-\w$/', $iterator-current() ) ) { //iterate through whole argument stream for ( ; $iterator-valid(); $iterator-next() ) { //Check if reached next option if( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //Get current options $currOpt = $opts; //echo $currOpt\n; //Test if next stream is an option for ($iterator-next(); $iterator-valid(); $iterator-next() ) { if ( preg_match ( '/^-\w$/', $opts = $iterator-current() ) ) { //echo $currOpt $opts\n; //$handler($currOpt, $opts); $currOpt = $opts; } var_dump($iterator-valid()); } }//End if //echo
Re: [PHP] Re: Re: File upload in map drive with PHP
On 1/27/2012 5:41 PM, Michelle Konzack wrote: Merhaba Mehmet YAYLA, Am 2012-01-26 15:10:34, hacktest Du folgendes herunter: I'm using code this bellow. ...with an error! form enctype=multipart/form-data action=upload_file.php?upload=1 method=post input type=hidden name=MAX_FILE_SIZE value=3 / Select image:input name=userfile type=file/ input type=submit value=Upload / You can not use action=upload_file.php?upload=1 together with method=post Wrong! Try this... http://www.cmsws.com/examples/php/testscripts/linux4miche...@tamay-dogan.net/form_upload.php and you have to use form enctype=multipart/form-data action=upload_file.php method=post input type=hidden name=MAX_FILE_SIZE value=3 / input type=hidden name=upload value=1 / Wrong. See above. Thanks, Greetings and nice Day/Evening Michelle Konzack -- Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php