[development] Shortening file names downloaded from webpage

Stewart Robinson stewsnooze at gmail.com
Mon Sep 14 16:12:40 UTC 2009


Why not just md5() the full URL and store that instead.
i.e.

$filename = md5($arr['path']);

2009/9/14 nitin gupta <nitingupta.iitg at gmail.com>

> Hello,
> 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 'filename too long error' (
> http://drupal.org/node/505964). It happens because I was saving the image
> file with the name as basename($image_url).
>
> But to solve the issue, I am now trying this code to shorten the filename.
>
> $arr = parse_url($image_url);
> $filename = basename($arr['path']);
>
> 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?
>
> Regards,
> Nitin Kumar Gupta
> http://publicmind.in/blog
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/development/attachments/20090914/3009782d/attachment.htm>


More information about the development mailing list