[advanced search]
Results from the most recent live auction are here.
40 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Website Development
User Name
Password

Old 06-25-2008, 12:41 AM   · #1
Dr_Test
New Member
 
Trader Rating: (0)
Join Date: Jun 2008
Posts: 21
NP$: 0.00 (Donate)
Dr_Test is an unknown quantity at this point
"generating" a large file on remote server?

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


Please register or log-in into NamePros to hide ads
Dr_Test is offline   Reply With Quote
Old 06-27-2008, 03:25 PM   · #2
Jim_
NamePros Regular
 
Jim_'s Avatar
 
Name: Jim, of course
Location: Philadelphia
Trader Rating: (20)
Join Date: Aug 2005
Posts: 558
NP$: 14.30 (Donate)
Jim_ is a glorious beacon of lightJim_ is a glorious beacon of lightJim_ is a glorious beacon of lightJim_ is a glorious beacon of lightJim_ is a glorious beacon of light
Save The Children
generate_crap.php:
PHP Code:
<?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" /> &lt;- filename to create/append data to<br />
    <input type="text" name="filesize" /> &lt;- 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['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!
__________________
woop woop
Jim_ is offline   Reply With Quote
Old 06-27-2008, 05:12 PM   · #3
Dr_Test
New Member
 
Trader Rating: (0)
Join Date: Jun 2008
Posts: 21
NP$: 0.00 (Donate)
Dr_Test is an unknown quantity at this point
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 Code:
<?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" /> &lt;- filename to create/append data to<br />
    <input type="text" name="12328" /> &lt;- 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 by Dr_Test : 06-27-2008 at 05:16 PM.
Dr_Test is offline   Reply With Quote
Old 06-28-2008, 10:58 AM   · #4
Jim_
NamePros Regular
 
Jim_'s Avatar
 
Name: Jim, of course
Location: Philadelphia
Trader Rating: (20)
Join Date: Aug 2005
Posts: 558
NP$: 14.30 (Donate)
Jim_ is a glorious beacon of lightJim_ is a glorious beacon of lightJim_ is a glorious beacon of lightJim_ is a glorious beacon of lightJim_ is a glorious beacon of light
Save The Children
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.
__________________
woop woop

Last edited by Jim_ : 06-28-2008 at 11:02 AM.
Jim_ is offline   Reply With Quote
Old 06-28-2008, 06:35 PM   · #5
Dr_Test
New Member
 
Trader Rating: (0)
Join Date: Jun 2008
Posts: 21
NP$: 0.00 (Donate)
Dr_Test is an unknown quantity at this point
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?
Dr_Test is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Hunting Moon http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 03:03 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0