General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 18th, 2003, 02:03 PM
alisafwan alisafwan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: pakistan
Posts: 18 alisafwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to get ip of remote mechine

hi

i am trying to upload file through remote mechine on linux server's data base

so is there any function in php by which i could get the IP address of the local mechine on which i am opening the site

actully i want to send thet ip to linux mechine

or any java scrpit u ppl know


plz send me the code


it urgert plz send me till saturday noon


thanks ........




aLI sAFWAN

Reply With Quote
  #2  
Old July 18th, 2003, 02:10 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
It's not clear to me what you're asking. I think you're saying that you wish to obtain the IP of the machine you're using to browse the Web so that you can send it to a Linux server. If that's the case, you'll just need to run something like ipconfig or winipconfig to see what your IP is. Of course, you could also write a little script and include getenv("REMOTE_ADDR") and hit the script with your local machine to get the IP address. If neither of those suggestions answers your question, please try to clarify.

Reply With Quote
  #3  
Old July 18th, 2003, 03:57 PM
alisafwan alisafwan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: pakistan
Posts: 18 alisafwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thaks for reply

Hi Sir
Thanks for reply

actully i have made a project and one of its module is student registration and couse management system of my university

i have uploaded the pictures of students using and html page which pass the address of the image file to php file in a variable $var_Path
using fopen funtion i am opening the file on that path and read the contents of that file and store the contents in avariable $contents
and then using insert statement i am storing the it in database

in thre deployment phase i have accessed the web page from some remote mechine and use the same procedure to upload file
the $var_Path contains the value of let say C:\abc.jpg of local mechine

the variable pass the address to server which is linux mechine but there is no c:\abc.jpg in server so oi need ip of local mechine to concat with the address so that server could ass the exect path

my question is what is the php function i can use to get the ip of the viewer


plz reply me soon i have to finish that before sunday night

thanks

Reply With Quote
  #4  
Old July 18th, 2003, 04:14 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
If I understand accurately the method you've proposed for having users upload their files, you're confused about how the process works. You can't simply specify the IP address and path and automatically have access to any file on the user's system (though I'm frankly a little surprised Microsoft doesn't allow that).

Check out http://php.resourceindex.com/Comple...File_Uploading/ for some scripts you might look at to get ideas for how to do this.

For starters, your form will need to have an "enc-type" attribute so that it can process the uploaded file. Once you've done that, you'll need to do some validation in your PHP code to make sure people can't upload maliciously or overwrite important files like /etc/passwd. Then you'll just do whatever you want with the file that's been uploaded. If you're putting it in a database, you should probably use a blob field rather than a text field. I'd recommend instead storing the image on the server somewhere and putting a reference to it in the database, though this'd involve some checks to make sure you don't overwrite existing images. You save yourself database overhead by doing it this way. You also save yourself the trouble of having to output content headers when spitting the images back out.

Whatever you decide, you should forget this IP method and work on making sure you specify the enc-type in your <form> line and then process the $_POST variable for the upload field as a buffer containing the raw data of the image file.

Reply With Quote
  #5  
Old July 19th, 2003, 09:35 AM
alisafwan alisafwan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: pakistan
Posts: 18 alisafwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PROBLEM IN DETAIL

hi sir

first thing is that i am working on three mechines
there are two servers one is linux(172.20.5.35) and other is windows (172.20.5.34)

i am accesing these mechines by windows mechine 172.20.7.48


the code of html file is

<html>
<head></head>
<body>
<form method="POST" action="testing123.php">
<input type="file" name="F1" size="20">
<input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>



and php file is


<?php
$connection=mysql_connect("localhost","root","") or die ("could't connect to server");
$db=mysql_select_db("CiitPortal",$connection) or die ("Couldn't select database");
$image = $_REQUEST['F1'];

$fp = fopen("$image", "rb");
header( "Content-type:application/octet-stream");
$content = mysql_escape_string(fread($fp, filesize("$image")));


$sql2="INSERT INTO Tbl_Image( Image )VALUES('$content')";
$sql_result2=mysql_query($sql2,$connection) or die ("Could't insert");

?>



when i am accessing windows mechine i am sending path

\\172.20.7.48\c$\game\12.jpg

it is accepting the path and image stores i the database the data type is blob
but on linux mechine it is giving me errors

********************
Warning: fopen("\\\\172.20.7.48\\c$\\game\\12.jpg", "rb") - No such file or directory in /var/www/html/project/testing123/testing123.php on line 14

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/project/testing123/testing123.php:14) in /var/www/html/project/testing123/testing123.php on line 15

Warning: stat failed for \\\\172.20.7.48\\c$\\game\\12.jpg (errno=2 - No such file or directory) in /var/www/html/project/testing123/testing123.php on line 16

Warning: Supplied argument is not a valid File-Handle resource in /var/www/html/project/testing123/testing123.php on line 16


*****************************


sir plz help me..
Coz u r the only one replying me

aLI sAFWAN

Reply With Quote
  #6  
Old July 19th, 2003, 11:54 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Ali,

Try adding this encoding type to your form tag:

[code]
<form method="POST" action="testing123.php" enctype="multipart/form-data">

If you notice the error message that's being spit out when you're trying to connect to the linux box, it's adding extra slashes... But if you notice, your directory "$c" doesn't have a slash added to it.... In PHP, variables must start with a $ sign..

Try escaping the $ sign in your directory... My suggestion would be to NOT use a directory with that style... Remove the $ and create a directory that doesn't make use of special characters.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #7  
Old July 19th, 2003, 03:23 PM
alisafwan alisafwan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: pakistan
Posts: 18 alisafwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for Helping

Hi Sir
first of all thanks for helping
one thing i want to tell u that $ sign is not name of directory cut i am specifing the path

\\172.20.7.48\c:\game\12.jpg
like

172.20.7.48\c$\game\12.jpg

because if i open run in your start menu and type
\\172.20.7.48\c$

it will open the c drive of the computer having ip 172.20.7.48

so i am trying to specifying the path



secondly can u plz tell me the functionality of
enctype="multipart/form-data
and how what l will recive on the php end

thanks
waiting for reply
aLI sAFWAN

Reply With Quote
  #8  
Old July 20th, 2003, 10:45 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Re: Thanks for Helping

Quote:
Originally posted by alisafwan
one thing i want to tell u that $ sign is not name of directory cut i am specifing the path

\\172.20.7.48\c:\game\12.jpg
like

172.20.7.48\c$\game\12.jpg

because if i open run in your start menu and type
\\172.20.7.48\c$

it will open the c drive of the computer having ip 172.20.7.48

so i am trying to specifying the path

secondly can u plz tell me the functionality of
enctype="multipart/form-data
and how what l will recive on the php end


I'm still confused on how c$ translates into c:?!

The "enctype="multipart/form-data" will specify the form as sending multi-part data, which is binary data (non-text)... So when you're choosing the file from the "browse" box, it will transfer the file as binary data so that you can then process it, using your PHP, however you like.

Try this:

- Put the enctype coding in your form tag, and select a file to upload.
- In your PHP script, output the filename that is sent from the form:

Code:
echo("Filename: " . $_FILES['name_of_form_field']);


Replace "name_of_form_field" with whatever name you gave your "filename" field in the form... And see what is output.

Let me know...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > how to get ip of remote mechine


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT