Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Upload data to file from a specified post='thefiledata'

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Upload data to file from a specified post='thefiledata'

Postby mikk809h » Tue Apr 01, 2014 11:03 am

Hello

I am trying to make a basic website with an Lua emulator, which is going to upload a long string(a file),
so it can be processed and uploaded to the web...

I have the following code:
Code: Select all
<?php
  $postdata=$_POST['POSTDATA'] or "WRONGDATA";
  $posttype=$_POST['POSTTYPE'] or "WRONGTYPE";
  $postname=$_POST['POSTNAME'] or "WRONGNAME";
  /*echo $postdata;*/
  $currentPath=$_SERVER['PHP_SELF'];
  $endPath=$currentPath.'/files/' . $posttype . '/' . $postname;
  move_uploaded_file($postdata, $endPath); /* but this line wont work with postdata... :( */
?>


I am uploading a long text with the following command line
Code: Select all
http://mywebsite.com/dev/upload.php?POSTDATA=allfiledata&POSTTYPE=program&POSTNAME=testprogram



Any help ie very appreciated!


Thanks in Advance
mikk809h
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu May 16, 2013 5:45 am

Re: Upload data to file from a specified post='thefiledata'

Postby seandisanti » Wed Apr 02, 2014 1:18 am

http://us3.php.net/manual/en/function.m ... d-file.php That page gives example of uploading multiple files and then moving them around. You should be very careful with what you're making, that's an idea that opens a lot of attack vectors to your web server. Whenever someone has the ability to arbitrarily execute code or get your server to parse arbitrary files, you increase the odds of privilege escalation attacks, injection attacks, etc. It's never a bad idea in those situations to serve the file from a virtual machine that has no rights to other resources on the computer or network. Just something to think about.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.