Bonjour, actuelement mon code est fait tel que le fichier est cree en .XML puis zip et depose dans le FTP.
moi j aimerais que le fichier sois uniquement en xml et depose dans le ftp.
voici le code:

public function postExportXML2(){
ini_set('max_execution_time', 0);
if(Input::get('generate_export') == "france"){
$ids = Input::get('car_id');
if($ids){
$carSite = CarSite::whereIn('car_id', $ids)->where('site', 'france')->get();
$franceIDs = [];
foreach($carSite as $france){ $franceIDs[] = $france->car_id; }
$getCars = Car::whereIn('id', $franceIDs)->with('images')->get();
}else{
$carSite = CarSite::where('site', 'france')->get();
$franceIDs = [];
foreach($carSite as $france){ $franceIDs[] = $france->car_id; }
$getCars = Car::whereIn('id', $franceIDs)->with('images')->get();
}
$content = View::make('admin.carmanager.exportXml2', compact('getCars'))->render();
//$filename = 'XML-Export-' . uniqid() . '.xml';
$filename = 'XML-Export-' . uniqid() . '.xml';
// set up basic connection

        $conn_id = ftp_connect("ftp.moustanche.com");

        $login_result = ftp_login($conn_id, "moustache", "azerty");

        ftp_pasv($conn_id, true);
        File::put(storage_path() . '/' . $filename, $content);
        if(!file_exists(storage_path() . '/france')){ mkdir(storage_path() . '/france', 0755, true); };
        $zip = new \ZipArchive;
        $zip->open(storage_path() . '/france/AA123286.zip', \ZipArchive::CREATE|\ZipArchive::OVERWRITE);
        $zip->addFile(storage_path() . '/' . $filename, 'AA123286.xml');
        $zip->close();
        if(ftp_put($conn_id, "AA123286.zip", storage_path() . '/france/AA123286.zip', FTP_BINARY)){
            // echo "successfully uploaded\n";
        }else{
            // echo "There was a problem while uploading";
        }
        // close the connection
        ftp_close($conn_id);
        //  return Response::download(storage_path().'/'.$filename);
        return redirect()->back()->with('message', 'XMl Sucessfully Posted');

1 réponse


pardonnez moi j ai pas reussi a mettre tous le code en fond bleu