-1

I'm trying to automate the import of a product catalog for my ecommerce and i'm wondering if it is possible to download the file remotely and use it directly from code without first downloading it manually and then import it. This is the portion of code where the addon sets the paths, if i could just add some code to download the file and place it in the "csv_upload_folder" before the import i think it can work perfectly

define('CSV_IMPORT_FOLDER', 'csv_import/');
define('CSV_IMPORT_INI_FILE', CSV_IMPORT_FOLDER . 'csv_import.ini');
$config = parse_ini_file(CSV_IMPORT_INI_FILE, true);

define("CORRECT_FIELDS_COUNT", (isset($config["settings"]["correct_fields_count"]) && $config["settings"]["correct_fields_count"] == 1)); 

define('CSV_IMPORT_UPLOAD_FOLDER', CSV_IMPORT_FOLDER . $config["settings"]["csv_upload_folder"] . '/');
define('CSV_IMPORT_PHP_FILE', basename($PHP_SELF));
define('CSV_DEBUG', (isset($config["settings"]["debug"]) && $config["settings"]["debug"]));

This Code is part of the "easy csv import" by "cozmo"

Thank You

5
  • You should quickly add what you have tried (including a minimal coded example) or you will get downvoted. Read the rules for asking questions on this site. Dec 1, 2014 at 9:26
  • Your question is ambiguous and poorly written. Also, I think you might be messing up 'upload' and 'download'.
    – Rohan Sood
    Dec 1, 2014 at 9:31
  • I didn't add the code because it's not mine, the addon allows me to import a csv file from my computer but i would like to import it directly from the server.
    – Mariano
    Dec 1, 2014 at 10:13
  • @Mariano Even if the code isn't yours, please add it (with attribution of course). Please do not link to off-site resources for code.
    – AStopher
    Dec 1, 2014 at 10:18
  • I'm adding the code but I think we are moving away from the problem, beyond of the addon I would like to know how to download a file and then use it in a script without downloading it manually.
    – Mariano
    Dec 1, 2014 at 10:21

1 Answer 1

0

I managed to do it, i used file_put_contents("Tmpfile.zip", fopen("http://someurl/file.zip", 'r')); to download the file in the same dir of the script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.