FOpen?

Posted on Sunday 20th May 2007 at 06:24 PM
Diablosblizz
Diablosblizz's Avatar
Hey, I want Fopen to create a file using the type 'x'. Heres what I got so far:
PHP Code
  1. fopen('url' 'x');


How can I make the file name be random. I know that I should use a randomizer, but how do I set the name?

Does anybody know, thanks!
Posted on Sunday 20th May 2007 at 07:56 PM
DanielXP
DanielXP's Avatar
PHP Code
  1. <?
  2. //Random number alpha (Letters + Numbers)
  3. $alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  4. //Make the random name
  5. $filename = substr(str_shuffle($alphanum), 0, 5);
  6. //Set as w for open for writing only
  7. $new_file = fopen("$filename", "w");
  8. //Stuff you want to go into the file
  9. $input = 'Some stuff you want in the file goes here..';
  10. fputs($new_file, $input);
  11. fclose($new_file);
  12. ?>


That makes a random name and saves it as a file
Posted on Sunday 20th May 2007 at 08:46 PM
Diablosblizz
Diablosblizz's Avatar
PHP Code
  1. //Random number alpha (Letters + Numbers)
  2. $alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  3. //Make the random name
  4. $filename = substr(str_shuffle($alphanum), 0, 5);
  5. //Set as w for open for writing only
  6. $new_file = fopen("https://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/$filename", "w");
  7. //Stuff you want to go into the file
  8. $input = 'Some stuff you want in the file goes here..';
  9. fputs($new_file, $input);
  10. fclose($new_file);


I added that. I want to create the file into here:
Code
https://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/


And I get this error with the code above:

Code
Warning: fopen(https://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/90fat) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 62

Warning: fputs(): supplied argument is not a valid stream resource in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 65

Warning: fclose(): supplied argument is not a valid stream resource in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 66



Help :(!
Posted on Sunday 20th May 2007 at 09:10 PM
SkillMaster
SkillMaster's Avatar
CHMOD the file to 777 lol. it has no write permissions
Posted on Sunday 20th May 2007 at 10:37 PM
Diablosblizz
Diablosblizz's Avatar
I CHMODed the file to 777 (shop.php). Same error..

Note:

Code
Warning: fopen(https://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/MSF7Q) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 62


Its trying to open that file, when there is no file. I want it to create the file with a random name, and then put a variable called $gm.

Any ideas?
Posted on Sunday 20th May 2007 at 10:52 PM
DanielXP
DanielXP's Avatar
Try getting rid of the full URL.

PHP Code
  1. <?
  2. //Random number alpha (Letters + Numbers)
  3. $alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  4. //Make the random name
  5. $filename = substr(str_shuffle($alphanum), 0, 5);
  6. //Set as w for open for writing only
  7. $new_file = fopen("forbidden/habbo/habs/habs/database/vouchers/$filename", "w");
  8. //Stuff you want to go into the file
  9. $input = 'Some stuff you want in the file goes here..';
  10. fputs($new_file, $input);
  11. fclose($new_file);
  12. ?>
Posted on Sunday 20th May 2007 at 10:58 PM
Diablosblizz
Diablosblizz's Avatar
I cannot remove the forum post because I am putting this code on frihost, but the server IP is on my computer.
:S.
Posted on Monday 21st May 2007 at 11:05 AM
DanielXP
DanielXP's Avatar
Host the script on your xammp host then.
Posted on Monday 21st May 2007 at 02:06 PM
Diablosblizz
Diablosblizz's Avatar
Now thats an Idea !!! :P - Thanks!
Login or register to respond to this forum topic.