Hi @deardevils
Please try using this format in the “Download from URL” field instead:
[custom_file_download("ftp://username:[email protected]/full/path/to/file.csv","csv")]
Let me know how it goes.
Thread Starter
DTECHNZ
(@deardevils)
Hi there,
That the one I currently use, with my own ftp info and path, also ” is correct without extra white space. However,I keep getting errors like below.
”
The URL to your file is not valid.
Please make sure the URL starts with http:// or https://. To import from https://, your server must have OpenSSL installed.
Unable to download feed resource.
WP All Import unable to detect file type.
WP All Import not able to determine what type of file you are importing. Make sure your file extension is correct for the file type you are importing.
Please choose the correct file type from the dropdown below, or try adding &type=xml or &type=csv to the end of the URL, for example http://example.com/export-products.php?&type=xml
“
Hi @deardevils
That the one I currently use, with my own ftp info and path, also ” is correct without extra white space. However,I keep getting errors like below.
That’s pretty strange. Have you tried downloading the file manually via FTP and manually uploading it to the import?
If that works, then you should add some logging in the code to see where it’s failing, and also check the file that the code puts in the uploads folder to see if it’s correct.
If manually uploading the file fails, could you send me a copy of it? If you’re not comfortable sharing it publicly then you can send it via a support ticket on our website instead: http://www.wpallimport.com/support/.
Thread Starter
DTECHNZ
(@deardevils)
Hi there,
The file itself is ok without problems.
Also I use chrome and put the url like this ftp://username:[email protected]/full/path/to/file.csv
and the browser can download this file to my pc.
Manually upload also works great.
Very strange in this case and the error messages are not showing much info.
I use the following code in my founctions.php, can you please take a look and see if I missed something? Thanks heaps.
function custom_file_download($url, $type = 'csv'){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
/* Optional: Set headers...
* $headers = array();
* $headers[] = "Accept-Language: en";
* curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
*/
$result = curl_exec($ch);
if (curl_errno($ch)) {
exit('Error:' . curl_error($ch));
}
curl_close ($ch);
$uploads = wp_upload_dir();
$filename = $uploads['basedir'] . '/' . strtok(basename($url), "?") . '.' . $type;
if (file_exists($filename)){
@unlink($filename);
}
file_put_contents($filename, $result);
return str_replace($uploads['basedir'], $uploads['baseurl'], $filename);
}
-
This reply was modified 6 years ago by
DTECHNZ.
Hi @deardevils
The code is fine. Does your password have special characters like “]”, “@”, “#”, etc? If so, try encoding those characters as per this guide: https://www.w3schools.com/tags/ref_urlencode.ASP.
Thread Starter
DTECHNZ
(@deardevils)
Thanks for letting me know.
Your support team has sorted it out already.
I did have the “@” in my p/w, that caused the issue.
All good now, thanks.