Upload file issue

Discussion in 'Programming' started by incdeveloper, Mar 27, 2007.

  1. #1
    Its possible to store (upload) in my server a file from other website that is not mine ?
     
    incdeveloper, Mar 27, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    yes, would you like an example of that ?
     
    krakjoe, Mar 27, 2007 IP
  3. incdeveloper

    incdeveloper Well-Known Member

    Messages:
    269
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #3
    yea that will be cool!!!... i have been looking for that for about 5 hours
     
    incdeveloper, Mar 27, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    in the crudest possible way :

    
    <?
    if( !function_exists("file_put_contents") ) :
    	function file_put_contents( $filename, $data )
    	{
    		$handle = fopen( $filename, "wb" );
    		if( !$handle ) die("Cannot write to filesystem");
    		$res = fwrite( $handle, $data );
    		fclose( $handle );
    		return $res;
    	}
    endif;
    if( $_POST['source'] ):
    	if( file_exists( basename( $_POST['source'] ) ) ) :
    		$messages = sprintf( "File %s exists on the server", basename($_POST['source']) );
    	elseif( @file_put_contents( basename( $_POST['source']), file_get_contents($_POST['source'])) ) :
    		$messages = sprintf( "File saved to %s", basename($_POST['source']) );
    	else:
    		$messages = sprintf( "Error saving file %s to %s", $_POST['source'] , basename($_POST['source']) );
    	endif;
    endif;
    ?>
    <html>
    <head>
    <title> Stealing Files </title>
    </head>
    
    <body>
    	<?=$messages ?>
    	<form action="" method="post">
    	Source : <input type="text" name="source" />
    	<input type="submit" value="Steal" />
    	</form>
    </body>
    </html>
    PHP:
    and the directory that file resides in needs to be chmod o+rw or 777
     
    krakjoe, Mar 27, 2007 IP