Why not just md5() the full URL and store that instead.<div><br></div><div>i.e.</div><div><br></div><div>$filename = md5($arr[&#39;path&#39;]);<br><br><div class="gmail_quote">2009/9/14 nitin gupta <span dir="ltr">&lt;<a href="mailto:nitingupta.iitg@gmail.com">nitingupta.iitg@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<div><br></div><div>I am maintaining a module FeedAPI ImageGrabber. It downloads a relevant image from a webpage of the feed-item and stores it along with the node. I found that the module sometimes gave the &#39;filename too long error&#39; (<a href="http://drupal.org/node/505964" target="_blank">http://drupal.org/node/505964</a>). It happens because I was saving the image file with the name as basename($image_url).</div>


<div><br></div><div>But to solve the issue, I am now trying this code to shorten the filename.</div><div><br></div><div>$arr = parse_url($image_url);</div><div>$filename = basename($arr[&#39;path&#39;]);</div><div><br></div>


<div>This code solves the problem by removing the query and fragments of the url. Does anyone know of any better way to handle this? Can anyone point out any issues with this code?</div><div><br></div><div><div>Regards,<br>


Nitin Kumar Gupta<br><a href="http://publicmind.in/blog" target="_blank">http://publicmind.in/blog</a><br>
</div></div>
</blockquote></div><br></div>