When I try to use ftp_delete() I get the error: Warning: ftp_delete(): File not found. My ftp server should be working fine, I can upload files fine to the same directory without a problem. Here is the PHP:
$fileSource = 'http://localhost/user/images/dfdf.png';
$ftpCon = ftp_connect('localhost');
ftp_login($ftpCon,'---','---');
ftp_delete($ftpCon,$fileSource);
Also when I look at the server logs I can see I get the message: 550 File not found
The url for $fileSource is the file's exact path, I went into localhost and copy/pasted it into the code, still for some reason it can't be found.
The ftp_delete function acccepts a path to the file. You are providing http://localhost/user/images/dfdf.png which contains the host (http://localhost/). I think you mean to provide /user/images/dfdf.png, which is just the path.
Example:
ftp_delete($ftpCon, '/user/images/dfdf.png');
When, for example, your FTP root is /user/, it will mean you need to provide ftp_delete with /images/dfdf.png. Thanks to #maremp.
Related
I'm trying to use Puppeteer and BrowserShot on an Ubuntu machine to make and screenshot of a static HTML.
The thing is that every time I try to make and screenshot:
Screenshot::loadView('monthly_resume.resume')
->waitUntilNetworkIdle(true)
->windowSize(1200, 630)
->noSandbox()
->storeAs($this->pathFor($user), 'image.php');
It returns an error. It seems that the HTML it's stored properly under a folder inside /tmp, in this case tmp/441150534-0230735001662479158/index.html.
But when node tries to find it says that the file it's not found even when it's there. Any idea why node can't find it?
Symfony\Component\Process\Exception\ProcessFailedException
The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=`npm root -g` node '/home/forge/monse.app/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/441150534-0230735001662479158\/index.html","action":"screenshot","options":{"type":"png","path":"\/tmp\/1562301876-0230606001662479158\/BrowsershotOutput1662479158hbgfB.png","args":["--no-sandbox"],"viewport":{"width":1200,"height":630},"displayHeaderFooter":false,"waitUntil":"networkidle0"}}'" failed.
Exit Code: 1(General error)
Working directory: /home/forge/monse.app
Output:
================
Error Output:
================
Error: net::ERR_FILE_NOT_FOUND at file:///tmp/441150534-0230735001662479158/index.html
at navigate (/home/forge/node_modules/puppeteer/lib/cjs/puppeteer/common/Frame.js:225:23)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Frame.goto (/home/forge/node_modules/puppeteer/lib/cjs/puppeteer/common/Frame.js:195:21)
at async Page.goto (/home/forge/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1143:16)
at async callChrome (/home/forge/monse.app/vendor/spatie/browsershot/bin/browser.js:249:26)
I encountered exact error message that you got. But then I just change temp path and its working fine. I'm using spatie/browsershot by the way
To change temp path at spatie/browsershot:
Browsershot::html('some html string')
->setCustomTempPath('/home/your/other/path')
->save('filename.jpg')
if i try the following command:
$_content = file_get_contents("ssh2.sftp://".intval($sftp)."/Lorem-62398848890105_20190117-101229.txt");
it works and i get the correct content.
But whenever I want to have all the files of the remote folder, the directory can not be opened.
I tried scandir or opendir. Both of these raises this message:
Warning: scandir(): Unable to open ssh2.sftp://12/ on remote host
What im doing wrong? Some tips would really help me.
Regards
Context: I use PHP 7.0.32 and ssh2.so is fully installed
UPDATE: I got it. I think it is due to a wrong attitude of the provider.
How it works:
$handle = opendir("ssh2.sftp://".intval($sftp).ssh2_sftp_realpath($sftp,".").'./');
The function ssh2_sftp_realpath + './' do the trick.
I'm sorry about my bad english.
I have encountered this error after installing the lamp server with this code. Previously, my same file system was working properly.
Lamp Server İnstall Command: "sudo tasksel install lamp-server"
Config File : define("URL", "http://localhost/test/");
Code: header("location:".URL."login");
Result: http://localhost/test/templates/URLlogin
I have no idea what the source of the problem is. Although I searched the web, I couldn't get any results. Thank you in advance for your help.
Respects
If you are getting URL printed instead of your constant, its because it is not defined in your current scope.
Is your config file being included or required at all anywhere? I would suggest it is not.
The default PHP behavior is to use the constant name as a string if it is not defined.
This would also trigger a warning in your logs.
Eg if you
define('URL', 'your url);
In one file, but do not have access/scope in another then using URL will give it to you as a string.
Eg
header('Location: ' . URL);
Will try to header over to 'Location: URL' instead of 'Location: your url'
I am trying to use
ssh2_scp_recv($connection, '/remote/directory', '/local/directory');
to get a remote directory, but I am getting the error:
Warning: ssh2_scp_recv(): Unable to receive remote file in /some-php-file.php on line 2.
It works if I use ssh2_scp_recv to get a single file.
Is this function supposed to work on directories? It wasn't clear from reading the docs.
You cannot use ssh2_scp_recv to get a directory. You can, however, use scandir using ssh2.sftp:// wrapper.
http://php.net/manual/en/wrappers.ssh2.php
Check this gist for an example credit for code to the gist owner danielbwa
I Am using send grid for codeigniter. My target is send pdf mail.
An uncaught Exception was encountered
Type: Guzzle\Common\Exception\InvalidArgumentException
Message: Unable to open http://website.com/projectdemo/webusa/uploads/files/ash.pdf for reading
Filename:opt/lampp/htdocs/projectdemo/webusa/application/third_party/sendEmail/vendor/guzzle/guzzle/src/Guzzle/Http/Message/PostFile.php
Line Number: 53
My PHP Code:-
$pdfFilePath = HOSTNAME."uploads/files/ash.pdf";
$this->sendMail($to, $subject, $message , $pdfFilePath );
You can not access a file with its HTTP path. Change it to the absolute path like below
root_directory/path/to/file/residing/ash.pdf
eg(local machine): D://my_folder/myfiles/ash.pdf
eg(live server): /public_html/myfiles/ash.pdf
When trying to post a file to a remote location, Guzzle requires that file to be local. You should look into downloading the file at http://website.com/projectdemo/webusa/uploads/files/ash.pdf and then uploading it.
If you are not keen on downloading the whole file into a temporary location and then uploading it back, one possible solution would be to use streams.
Have a look at this discussion as well:
Copy remote file using Guzzle
Try this
If inside application folder
$pdfFilePath = APPPATH."uploads/files/ash.pdf";
If Outside application folder
$pdfFilePath = base_url()."uploads/files/ash.pdf";