Jump to content

<?php fopen($_GET[‘I am a noob!’], ‘w’); ?>


Go to solution Solved by Jacques1,

Recommended Posts

Hey guys! I'm new in this community and also new to php.

So I'm building my personal and very unsafe "cloud" and here's the first problem:

 

What I want to do is: when typing http://x.com/docs/?new=file.txt, create a file in that directory (docs/file.txt).

 

Here's my very simple code (docs/index.php):

<?php
fopen($_GET[‘new’], ‘w’);
?>

And here's the error I get:

Warning: fopen(): Filename cannot be empty in /home/u344093746/public_html/p/s/docs/index.php on line 2

I've already changed permissions for the directory docs/

 

Thanks in advance!*

 

*Mind my English, I'm Spanish. Soz if I make you get a lil bit confused...

Edited by pedrwvargas
Link to comment
https://forums.phpfreaks.com/topic/303743--/
Share on other sites

  • Solution

“Very unsafe” is an understatement. This is malware. It allows anybody to (over)write arbitrary files at arbitrary locations, because you blindly accept any path. Unless you want to demonstrate how easily bad software can be compromised (which is already well-known), you're doing it wrong.

 

Then your code is full of typographic quotes which PHP cannot process. Appearently you use something like Microsoft Word instead of an actual code editor to write your programs.

  • Like 1
Link to comment
https://forums.phpfreaks.com/topic/303743--/#findComment-1545613
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.