|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
Re: Thanks for Helping
Quote:
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... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > how to get ip of remote mechine |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|