NameSilo

"Generating" a large file on remote server?

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

Dr_Test

Account Closed
Impact
0
Hello. I'd to test large files on my webhost, and was just wondering if there's any way to "generate" a several-gig file on my server, without having to upload one. (because I've been having trouble uploading anything greater than about 2 gigs or so with FireFTP and FrontPage).
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
generate_crap.php:
PHP:
<?php
// generate crap script. 
//
// make sure you have write permissions.
//
// it'll prolly time out for rediculously large files, 
// so if that happens, just run it again with the same 
// file name to append more data to the file.
// -Jim
if(!isset($_GET['filename']) || !isset($_GET['filesize']))
{
	?><form action="?" method="get">Generate Crap:<br /><br />
	<input type="text" name="filename" /> <- filename to create/append data to<br />
	<input type="text" name="filesize" /> <- filesize to add (in MB)<br />
	<input type="submit" />
	</form><?php
}
else
{
	echo "Writing data: ( each | = 128 bytes )<br /><br /><div style=\"font-size: 6px; height: 200px; overflow: auto;\">";
	$crap = "0123456789ABCDEFFEDCBA98765432100123456789ABCDEFFEDCBA98765432100123456789ABCDEFFEDCBA98765432100123456789ABCDEFFEDCBA9876543210";
	$filename = $_GET['filename'];
	$filesize = $_GET['filesize'] * 1048576;
	
	if($f = fopen("./".$filename,"a"))
	{
		for($i = 0; $i < $filesize; $i+= 128)
		{
			fwrite($f,$crap);
			echo "| ";
			ob_flush();
			flush();
		}
		fclose($f);
	}
	echo "</div><br /><br /><b><u>It's over!</u></b>";
}
This should work. I tested it up to 200MB.

Make sure to remove those spaces that the forum adds to the $crap = .... line. Stupid auto-word-wrap feature or whatever it is adding gaps to my script!
 
0
•••
Thanks, Jim...

So, if I want to generate a 12 GB file, will this work? (I'm not a coder, so I'm just guessing what I have to put in the file)

Notice also, I turned the $crap = into $crap= (no space), like you mentioned. (I just need to verify this)

PHP:
  <?php
// generate crap script.
//
// make sure you have write permissions.
//
// it'll prolly time out for rediculously large files,
// so if that happens, just run it again with the same
// file name to append more data to the file.
// -Jim
if(!isset($_GET['house.avi']) || !isset($_GET['12328']))
{
    ?><form action="?" method="get">Generate Crap:<br /><br />
    <input type="text" name="house.avi" /> <- filename to create/append data to<br />
    <input type="text" name="12328" /> <- filesize to add (in MB)<br />
    <input type="submit" />
    </form><?php
}
else
{
    echo "Writing data: ( each | = 128 bytes )<br /><br /><div style=\"font-size: 6px; height: 200px; overflow: auto;\">";
    $crap= "0123456789ABCDEFFEDCBA98765432100123456789ABCDEFFE  DCBA98765432100123456789ABCDEFFEDCBA98765432100123  456789ABCDEFFEDCBA9876543210";
    $filename = $_GET['house.avi'];
    $filesize = $_GET['12328'] * 1048576;

    if($f = fopen("./".$house.avi,"a"))
    {
        for($i = 0; $i < $10328; $i+= 128)
        {
            fwrite($f,$crap);
            echo "| ";
            ob_flush();
            flush();
        }
        fclose($f);
    }
    echo "</div><br /><br /><b><u>It's over!</u></b>";
}

...and then when I'm done, I assume I just browse to the generate_crap.php in the browser, and it will run?
 
Last edited:
0
•••
haha no no no.

Just upload the script as-is, but remove those gaps in the line starting with "$crap = ". No other editing necessary. Then, visit it in your browser and enter the filename and filesize you want into the input boxes and hit submit.
 
Last edited:
0
•••
Ahh, okay... thanks a lot, lol. :)

It's working beautifully, but after 30 seconds, it stops and spits out this at the bottom of the long text box: Fatal error: Maximum execution time of 30 seconds exceeded in /home/arbie/public_html/generate.php on line 31

I'm guessing my webhost server is disallowing operations longer than 30 seconds, right? (it's Lunarpages, btw)

Any ideas how to get around this, or change it?
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back