With the help of the @Math answer I remembered Curl to create POST.
So I started by creating my PHP script ( upload_test.php
) where I POST my file ( myfile_test.zip
) to gravar.php
and save the result to teste_results.txt
.
upload_test.php:
$user_id = rand( 1, 10 );
$local_file = '/my_dir/myfile_test.zip';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_VERBOSE, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)" );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_URL, 'http://localhost/gravar.php' );
$post_array = array(
"uploaded_file" => "@" . $local_file,
"function" => "upload",
"user_id" => "$user_id",
);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_array );
$response = curl_exec( $ch );
$myfile = fopen( "/my_dir/teste_results.txt", "a+" ) or die( "Unable to open file!" );
$txt = "\n=> AUTO_UPLOAD " . date( 'Y-m-d H:i:s' ) . "\n";
fwrite( $myfile, $txt );
fwrite( $myfile, "Fez upload? = " . $response . "\n" );
fwrite( $myfile, "\n" );
fflush( $myfile );
fclose( $myfile );
Curl Fountain
On the side of gravar.php
, so I get the file:
$uploaded = (object) $_FILES['uploaded_file'];
$file_name = $uploaded->name;
$file_tmp = $uploaded->tmp_name;
$file_type = $uploaded->type;
$file_size = $uploaded->size;
Then just add the line to the Crontab and I can create the lines you want to test my load server.
At the command line:
$ crontab -e
Insert the following line and record: (10 in 10 minutes)
*/10 * * * * /usr/bin/php /var/www/html/my_dir/upload_test.php
Source of crontab