I wrote a PHP script, which is creating some files.
After it finished i want it to open a folder, where the created files stored.
exec("explorer C:\\test");
Unfortunately it isn't open the folder at all.
I check it in cmd as well where it is working.
I also tried this:
shell_exec("explorer C:\\test");
Any hint or advise is greatly appriciated.
This can be done if your localhost is on your computer with windows operating system (I use xampp). Any cmd command will work with exec();
So for your question:
$path = "C:\your path";
exec('start "" "'.$path.'"');
Will open your folder in windows.
Why not use PHP's directory functions?
http://php.net/manual/en/function.dir.php
http://php.net/manual/en/function.readdir.php
I'm guessing that PHP can't open a GUI program, such as explorer, as it may not be able to access the user's display. Just my theory anyway. You could build a folder GUI using PHP and the aforementioned functions.
Related
I am creating a PHP web app to run on Linux where user can upload their spherical image and my script will turn it into VR image . I have created one but it runs on Windows and have no clue on how to port it to Linux.
I have downloaded Krpano for Linux from its official site and successfully create a VR image by dragging my image to the droplet.
Now I want to create the VR using PHP, is there any executable file to do this ? In Windows, I would do such " /path/to/krpano.exe /path/to/config /path/to/image.jpg", but when I extract the downloaded file from krpano.com there is no executable file (Or I don't know which one).
Anyone know how to execute krpano using PHP in Linux ? I found this tutorial here
http://krpano.com/forum/wbb/index.php?page=Thread&threadID=1306
but I dont understand how to implement it in my case.
Please help, thank you.
Linux and .exe
On Linux, everything is a file. Extensions, both as a concept, and a tip-off to the OS, don't exist.
On Linux, an extension, like '.exe', doesn't inform the operating system to do anything unique with the file, it only makes the name of the file longer and gives a hint to the user. To really know what a file is, run 'file' on it.
Any file with executable permissions and that passes the kernels checks, can be executed.
Your question
Make sure you follow the installation steps pointed out in the video they provide. Sounds like you have if you're successfully using the droplet.
Windows
/PATH/TO/krpano.exe /path/to/config /path/to/image.jpg
Linux
/PATH/TO/krpanotools makepano -config=templates/vtour-multires.config /path/to/image.jpg
I've not actually tried this, just pieced it together from looking at the exec parameter in the relevent droplet file. If this wasn't the droplet you wanted, open the droplet.desktop file in a text editor, extract the command from exec='...' and replace the above with that, followed by your file.
Hope that helps!
I've made an extension for my web application in php. I want the php script to remake the extension, so I'm trying to send a command to the terminal. It looks like this:
shell_exec("make -C /folder1/folder2");
And it won't make the .so file no matter what. I've used chmod 777 on that folder to make it editable but it didn't help. When I'm directly using the command in the terminal it works just fine:
make -C /folder1/folder2
The .so file gets created without a problem, functions from my extension work like they should. Does anyone have a solution for this?
Make sure that PHP is not running in safe mode and that the PHP user has read/write access to the files and folders. Read the comments at shell-exec for more information.
My setup is as follows: Windows 7, XAMPP with Apache and PHP enabled I have a PHP script in which I call an external program to do run a conversion. This external program is an EXE file, which requires 3 attributes:
The source file
The destination file
Additional flags (conversion type etc)
When I use the command line tool built into XAMPP to execute my script, everything works fine. But when I use the exec() function in my PHP script, no output file is created. I'm pretty sure the conversion is actually happening (it takes about 5 seconds, about the same time it takes to run the PHP script).
I think it's a permissions thing, so I already moved the EXE file to the same folder as my PHP file and adjusted the permissions of the entire folder (I granted all permissions to all users). I also disabled the Windows UAC and tried to put the command in a BAT file. The file just is not created.
Any help or tips would be greatly appreciated!
My PHP code is as follows:
exec('c:\converter.exe c:\src.txt c:\dst.txt -f', $output);
print_r($output);
When I print out $output, the array turns out to be empty. When I put the exact same command in Command Prompt, the code works like a charm (no syntax errors). I use absolute paths as well.
Try to copy your executable file in same folder as your application.
try
exec("script.exe src.txt dst.txt", &$output);
echo $output;
also, do not forget to use escapeshellcmd() to add some security to your application.
Thank you very much for your input! As it turns out, it was Windows issue caused by the 'Interactive Services Detection' feature. Apache was running as a system service, which prevented calls to external programs (with a GUI). I disabled the run-as-service feature in XAMPP, which solved the problem. A more thorough explanation can be found here: http://php.net/manual/en/book.exec.php
I'm using flare to decompile a flash movie. I need to do it via PHP. User visits PHP script, it decompiles the flash movie.
Here is how the files are set up on my web host:
index.php:
<?php
error_reporting(-1);
echo shell_exec('./flare movie.swf');
?>
Flare is supposed to create a file named movie.flr once the script runs, but there is no such file. I am thinking my shell_exec is wrong.
phpinfo() - http://zachafer.com/phpinfo.php
You're trying to execute the wrong file.
flare.tgz is an archive (not executable) containing the flare binary (executable).
Unpack it with an archiver tool like winrar on windows or tar on linux (tar xvf flare.tgz).
Inside the archive, you will find a file named flare. Try with this one and it might work if your host provider allow the shell_exec() function calls.
You can't execute a .tgz file directly! You need to unpack the executable before you can run it.
This function is disabled when PHP is running in safe mode... check it or ask your host provider about it
I think flare.tgz is not an executable but a .tar.gz file (it's like a zip file, but it is another format).
You have to unpack it first !
I just installed Apache and PHP on my computer to be able to run PHP files locally.
I can run a PHP file if it is located in Apache2.2\htdocs directory.
Is that possible to run PHP files outside this directory ?
I'm looking to a simple solution, because all I need is to write a small PHP code and try it locally.
I would like to be able to run the PHP file by right clicking it -> Open with Firefox
You can run a PHP script from anywhere using the command line:
php yourscript.php
There is some ways to do it, but the simplest way is using 'include' or 'required' php command:
<?
include ('/somewhere/outside/of/your/htdocs/file.php');
?>
Please note you may need to turn off 'open_basedir' php directive.
Newer versions of php come with php-cli: a command line interface. So to run php code, you just need to type:
php some_code.php
Or you can change paths in apache config to another dir
you cannot open it with firefox.
Because firefox has nothing to do win PHP.
So, you need to request this URL from a web-server
Create a windows shortcut with http://127.0.0.1/file.php
or whatever way you prefer to click web links
Yes. You don't say if you want to run it from the web server, or from the command line, but you can use include past the web root.
You can either run it from the command line,
or you can create a "wrapper" script within your htdocs that "includes" the file from outside of the htdocs directory
I had always wondered about it the same manner, say you have a folder in a drive either than the apache/htdocs folder in drive C, and you would like to develop directly in this folder. But think about it this way, would you put your folders else where and expect it to be running on the web? Now Way. Why would you do that?
Goto conf folder and open httpd file change
DocumentRoot "C:/your/path" and
Directory "C:/your/path"
This should work
if it says forbidden access go to this link
Error message "Forbidden You don't have permission to access / on this server"