Hi, please elaborate your question more. we can't help you if we don't understand what exactly you want to do (what is your input, process and output?)
function get_file($file, $newfilename) { $err_msg = ''; echo "<br>Attempting message download for $file<br>"; $out = fopen($newfilename, 'wb'); if ($out == FALSE){ print "File not opened<br>"; exit; } $ch = curl_init(); curl_setopt($ch, CURLOPT_FILE, $out); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $file); curl_exec($ch); echo "<br>Error is : ".curl_error ( $ch); curl_close($ch); //fclose($handle); }//end function // this is a simple download function that download remote file // but every time i need to use it i should give $url and $filename . // that im looking for is give only the $url download and save file // with same name that is on remote host // if file is called attachment.zip save it with same name // get_file("http://www.remote.com/files/attachment.zip");
Hi, you can use the php basename function function get_file($file) { $err_msg = ''; $newfilename = basename($file); /... nothing changed past here PHP:
basename and pregmatch cant help me if link is site.com/?down=2131 is any other way i can get only file name maybe not using curl
What has that got to do with filename?, vague description = vague reply. Please reply with an example input and expected output (such as a link, and where the filename comes from that link...), so we can help you better.
Can you please explain what you mean? No one here understands your problem. Explain in detail what you are trying to do and what your problem is.