can someone help me to get DESKTOP PATH?
echo "<input type='hidden' value='C:\Users\".getenv('USERNAME')."\Desktop'>";
it returns C:\Users\IT-TUPER$\Desktop
this is my desktop path C:\Users\Tuper\Desktop
In php by no means you can't have Desktop Path on a real server, as php is serverside. However if you're on localhost like xampp, wamp, or whatever on windows you try this :
<?php echo getenv("HOMEDRIVE").getenv("HOMEPATH")."\Desktop"; ?>
PHP files are in server, the client (browser) ask a petition to server (specific php file), the server render the answer, send it to client (browser).
For that reason, you canĀ“t get client path.
Related
I'm running this from Filezilla remote server
anyone have any solution
<?php
echo "what a lab";
?>
For a web browser to load the output of a PHP file you need to make an HTTP request to an HTTP server which supports PHP.
FileZilla is an FTP client. It connects to FTP servers. FireZilla, if it comes into it at all, will be used only to copy the PHP file to the computer which is running both an FTP and HTTP server.
You need to enter the matching HTTP URL (e.g. http://example.com/your.php) into the address bar of your browser.
Recently I have been trying to work with my ESP. I have set up a server using XAMPP on my laptop. I can access that server using 127.0.0.2. I know that the content viewed on this page is present in the htdocs folder in XAMPP.
So I have created a folder named TEST in htdocs. The ESP is connected to PSoC and is sending some data at regular intervals to the TEST folder on the server. My question is: what is the IP address that will be needed to connect to the server when I use the AT+CIPSTART command on the ESP side?
Is it 127.0.0.2 or some other IP from the router? I have tried sending data to ThingSpeak before and there they provide a ready-made GET request link to send data to the server. What will be the GET request link in my case if the server is created using XAMPP? Please help as I am new to networking. Thank you.
Ok. I wrote a php file which takes value in a variable SAP and writes into a text file which is stored in the ht docs folder. The php code is as follows
'
$content = "SAP ID :".$var1." is present for the lecture \r\n";
echo $content;
echo "<br >";
$status = file_put_contents('attendance_record.txt',$content,FILE_APPEND);
if ($status != false)
{
echo "Data is written to the file :p ";
}
else
{
echo "Data was not written into the file :( ";
}
?>'
After then I enable the Xampp server and access this file by using 'http://127.0.0.2/receiver.php?SAP=104' Until this point everything is working fine and the text file is being updated. Now the same thing is needed to be done via AT commands using the ESP. The following lines of code is running on the ESP side.
AT+CWJAP="SSID","PASSWORD"
AT+CIPSTART="TCP","192.168.0.104",80
AT+CIPSEND=35
GET /receiver.php?SAP=69 HTTP/1.1
Now i'm not getting any updates on the text file. Any help will be appreciated. Thank you.
172.0.0.2 is the same at calling 'localhost' so you would need your laptop's IP for the ESP to connect to. Depending on your OS you can find that opening your terminal and write ipconfig(windows) or ifconfig(linux) On a MAC go to System Preferences > Network and your IP is displayed under'Status:'
I have a webpage (HTML, CSS, JavaScript) hosted in a Nginx & Ubuntu & Digital OCean server. The webpage has a part where users could submit a file and call an application by PHP. I am wondering if it is possible to host this application alone in a Windows Server 2012 R2 & Microsoft Azure, which I have already.
Here is an example. This is the webpage (though the real webpage has much more contents) hosted in Ubuntu Server. The Upload the file button is linked to uploadFile.php:
<?php
copy($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);
$n1 = "uploads/" . $_FILES["file"]["name"];
echo "Uploaded: " . $n1 . "<br>";
exec("mono c1.exe $n1");
...
?>
The application c1.exe is developed in C# under Windows. Because its new feature uses ode32.dll, it cannot be run with mono anymore. So I have to host c1.exe in a Windows server.
And I don't want to move the whole website to Windows server. Moreover, if possible, I want the web address in the browser address bar to be always consistent when calling php (i.e., starting with www.matrixandcompany.com/...).
Does anyone know if it is possible to realise this mechanism?
Probably you can use curl (http://php.net/manual/en/book.curl.php). You can create a php file in the server where the c1.exe is, and call it from the old server.
I would transport the file to the windows server. There are many different ways to do this.
Then call a script on the remote server which will execute the binary.
I cannot think of a different AND SECURE way.
If i have a local file, for example, c:/test.txt, what path do i need to type in the ftp_put function to make it work (string $local_file)? When i try with "c:/test.txt" i get an error.
Thanks
Its on a remote server. Am i using wrong php function? I want to upload a local file to a remote ftp ...
Yes, you're using the wrong function.. Remember - PHP executes on the SERVER, not in your browser and not on your local machine. Any FTP connection you establish in the PHP script will be relative to the server.
e.g. If you've got something like this:
(your machine) ----> (your website) ----> (other machine you ftp to)
The FTP connection will be between "your website" and "other machine you ftp to". Any "local" path you specify for a file will be local to "your website", not "your machine".
You'd first have to upload the file via regular HTTP file sending mechanisms via a form on your site, which gets the file from "your machine" to "your server". The PHP script which handles the upload can then use the FTP functions to transfer the file from "your website" to "other machine you ftp to".
I think that if you have to use ftp to pull a file off your machine (as opposed to using a html form) your best bet would be to set your local machine up as an ftp server. You would probably need an static ip address for this to be consistent. You could then have your script connect to your local machine and use ftp_get to grab test.txt.
how to test if a file exist on the current computer using the application ?
I try to put the full url at my file like this, but it doesn't work :
if(file_exists("C:/wamp/www/project/photo/".$nom_photo))
{
echo "file exist";
$extension=pathinfo("C:/wamp/www/project/photo/".$nom_photo,PATHINFO_EXTENSION);
echo "<br>";
$nom=md5($nom_photo.time().rand(0, 99999)).".".$extension;
echo $nom;
rename("C:/wamp/www/project/photo/".$nom_photo,"C:/wamp/www/project/photo/".$nom);
echo "<br>";
}
How to fix it ?
PHP operates server side and has NO ACCESS to the files on the machine running the web browser, unless they are indeed the same machine.
If you are meaning to find a way to test if a file exists on the web server, the file_exists() function you mentioned should find it. There are many reasons this might fail, including safe_mode, file permissions, and using the wrong path.
The server doesn't have any access to the clients filesystem, this would be a major security flaw.
Also javascript is sandboxed so you couldn't do it on the client side either.
The only way I can think of doing this is to get the user to download a separate application that looks for the file and reports back to the server.