Re: PHP IP Checking...



Josh "Ramen" Miller wrote:
Ok, this seems like it should be really simple.

On my server/website I have a very basic upload script and page.  It takes
file, it uploads it to a directory, you may browse the directory.  Anyone
can upload files etc.

I want to create a second "copy" of this page and script (which I've done)
but I want it to only accpept uploads from PCs with the same IP as the
server (ie only I can upload to it).  This seems like it would be a realy
easy thing to add to my upoad script.

Actually on a related note I wouldn't mind adding usernames and password and
a bit more sophistication to the upload page but freankly, I know nothing
about PHP.  I picked up the upload script off of a simple tutorial
somewhere.

$_SERVER['REMOTE_ADDR'] gives you the ip of the machine that loads the page, just use an if statement to see if it's your server or not, don't forget that both the 127.0.0.1 and the public-ip are valid for your server.


When it comes to logins, you just have another if-statement where you compare the form-password/username to what you have stored somewhere (file/database/directly in your php-script).

For more information about php, visit http://www.php.net/manual/en


//Aho .



Relevant Pages

  • Re: FTP (urgent): can upload from explorer but not using FTP utility????
    ... I can't upload using FTP.exe ... I have an FTP server which works fine. ... I can upload files using the windows explorer. ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: Chmod
    ... Only if you can ftp in as the web server. ... he was asking how to upload files with PHP - not with FTP. ...
    (comp.lang.php)
  • Re: FP Upload File Size Limit?
    ... hosting server. ... FrontPage Resources, WebCircle, MS KB Quick Links, etc. ... > I can upload files much larger than that. ...
    (microsoft.public.frontpage.client)
  • Re: Chmod
    ... Only if you can ftp in as the web server. ... he was asking how to upload files with PHP - not with FTP. ...
    (comp.lang.php)
  • Re: Chmod
    ... Only if you can ftp in as the web server. ... he was asking how to upload files with PHP - not with FTP. ...
    (comp.lang.php)