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
Related
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.
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
I am making a contact us page for a website. I have the html page defining all the input criteria such as name, email and message. This html file links to a php file to send the information that the user types into the message box.
my problem is that I cannot test if sending the message will work as I think the php file needs to to be run through a server. How can i test if the file works on my mac?
You should put your .php file in the htdocs folder of MAMP or XAMP. After that you must copy your file path in your browser. Replace everything up to and including htdocs with your localhost. For example: If my file is in Users/Documents/MAMP/htdocs/index.php it should be like localhost:8888/index.php
You can download mamp or xamp and install server on your mac. Then you can test your all php files.
Here is my prob in Brief.
I know how to upload a file to server using FTP with programming language PHP.
But is that possible to transfer files from one directory to another directory. In the same server....
I have the two paths of the directorys...
Any idea how?
I'm using two computers (both connected to one network) and one of them has XAMPP. I'm trying to upload files to the one with XAMPP in it (the files are from the other computer). But I always end up having the 'No such file or directory' error even though I have the correct path. But when I use the path from the computer with XAMPP, even when I'm using the other computer, the system works just fine. Can anyone help me?
P.S. I'm using PHP copy() function because the file path is coming from an excel file.
Here's the part of my PHP code:
$original_file_name = objWorksheet->getCellByColumnAndRow(5,$i)->getValue();
// Example of the cell value: C:\Users\ComputerWithoutXAMPP\Desktop\scanned documents\SO 2010\#1.jpeg
$ext = pathinfo($original_file_name, PATHINFO_EXTENSION);
$file = time().substr(md5(microtime()),rand(0,26),5);
// UPLOAD THE FILE DECLARED IN EXCEL
copy($original_file_name, 'uploads/docs/'.$file.'.'.$ext);
You can use copy() to upload a file to another machine, or from another machine, but to access the remote machine, the appropriate argument to copy (source or dest) has to be a URL. The code you've posted is trying to copy the file to a local "uploads/docs/" directory, it's doesn't even appear to aware of another machine.
While what you're looking to do may be technically possible, I haven't the foggiest idea how you'd go about it: it seems rather Rube Goldberg to me. The ftp:// wrapper would probably work, if FTP is set up properly on the XAMPP server.
How big is the file you're trying to send? If it's small enough, you may have better luck either encoding and sending the content itself or uploading the file with curl to an upload-catching script on the XAMPP side