Downloading FTP file using Codeigniter Filepath Error - php

This is what I have done so far.
Configured Filezilla FTP server on localhost.
And added user: Admin with shared folder C://ftp
there is a file inside that folder 123.jpg
So when I try to Download it using ftp class in Codeigniter;
Unable to download the specified file. Please check your path.
this is the code I'm using to download. FTP successfully connects but fails download due to incorrect file path.
$this->ftp->download('/123.jpg', 'D:/');
What should be changed in the above code?

Well, D:/ definitely dose not seems to be a path that is wrong. As for the doubt goes in the file you trying to download.
You can debug with the same - connect the ftp server using a ftp client, see the files / folders in list. There you can confirm as whether or not the file exists directly in path or not.

Solved it !
Seemed that local file path need to have the 'file name' at the end as well.
$this->ftp->download('/123.jpg', 'D:/blah.jpg');
And file would be downloaded to D: renamed as blah.jpg

Related

PHP File Upload to remote server

I am currently having problems with testing a known working file upload script while migrating a site to a new server.
I have migrated the entire site to the new server and everything works as it should apart from the original file upload script. I have not pointed the domain names to the new server as yet, accessing it through changing my hosts file on my local machine.
Before writing a simple upload test script, could there be any reason I am missing that is preventing my file uploads from working - for example, security issues?
Is it likely that the file upload directory location is pointing to the original server?
Please, put all the files in the content folder directly to the public directory of the live server.
E.g: Select all in the content folder and paste it directly on the public folder.

aws php script uploaded file permission issue

I have a php site hosted in aws ec2 server.
While uploading files using php script it have only 0644(rw-r--r--) permissions in server. i need to change the file permissions to 0777(rwxrwxrwx).
What am doing is .. uploading a file and then read it and create a new encripted file using it and then delete the first file. its not happening because of file permission issue in aws uploading file through script.
uploaded files shows owner as 'apache' and transfer file using winSCP shows 'ec2-user'.
please help , am not much experinced in aws , so please please send your answers in detail.
Try This one.
Hope it will work
move_uploaded_file($temp_file, $UploadDirectory.$NewFileName );
chmod($UploadDirectory.$NewFileName, 0755);
$in_filename = $UploadDirectory.$NewFileName;
$aes_filename = //your path to new file with name;
$this->encryptFileCBC($in_filename, $aes_filename);
unlink($UploadDirectory.$NewFileName);

PHP - finfo class not found. unable to upload file after deploying site online

I am building a web application using ExtJS4 and PHP5. There is a part where I upload a photo and as I was testing it locally, I am able to upload photos properly to a folder in the file directory.
After I deployed the file to our server online, I tested it. At first, I was getting a class finfo not found, at it pointed to my upload.php file and and to the line:
$finfo = new finfo(FILEINFO_MIME_TYPE);
Upon googling the problem, I needed to make sure that my php.ini file allowed file uploads. So what I did was I made my own php.ini file in the server and I copy pasted the contents from the php.ini file located in ../MAMP/conf/php5.5.10/php.ini but I got an error that I'm trying to decode an invalid JSON String. I also tried ../MAMP/bin/php/php5.5.10/conf/php.ini but I still get the same error.
I don't understand what's happening. I think I'm copying the wrong php.ini file to my server. I am using Freehostia and we are not allowed to access the php.ini file and it was advised to create my own php.ini file. However, so far, copy pasting my php.ini file did not work. It may be that I'm constructing the file wrong.
It's the fist time I've deployed a site that required a file upload, usually I just work with database CRUD and that works.
I found a PHP Settings Page in the home page. I set the PHP to 5.5 and made sure it allowed file uploading.

Upload local file to FTP server using PHP

I have searched everywhere but didn't got a perfect answer.
I am using WAMP to run PHP on local machine. I have an tag to accept file from local machine and have to upload this to FTP server.
My code is working perfectly fine but only if file is present directly on base path i.e. /wamp/www/ but if I pick file from desktop to upload, it didn't actually pass path of file to action php file instead just pass on file name.
Is there a way to achieve this functionality?
Thanks
Saransh

move_uploaded_file returns true but file does not appear in folder

I have a couple of scripts that worked fine on another server.
Now that I have moved everything on to a new server, the file does not appear in the destination folder. The strange thing is that move_uploaded_file returns true.
Also, I printed the post data and there is no error.
Can you guess what's possibly going on. The files I am trying to upload as a test are very small ( 10 kb).
The move likely succeeded, check the following:
You don't have access to view the file.
Use chmod("/path/to/file.ext", 0755); to add view rights for the ftp user.
You moved the file to an location that doesn't store the file. /dev/null
You're looking in the wrong folder. Did you use a full path?
The file is removed shortly after the move.
In my case, Total Commander, used as an FTP client, truncated output to 10000 files in directory. When I connected via SSH using WinSCP I was able to see all ~14000 files in the directory.

Categories