Jump to content

zip file naming problem


serious1234

Recommended Posts

I have a script that put a file in zip archive and make it available for download. my problem is that when i download those zipped files they come with number.. for example my file is something  like  avenging.srt and when it becomes avenging.[1].srt.zip  . everything is ok but my problem is with the dot before the file extension srt. Everytime i download the same file it changes to the same name with different number like avenging[2].srt.zip , avenging[3].srt.zip and when i use a name without extension like avenging it is ok the zip file comes as I want it to be.

and this is part of the code:

---------------------------

 

 

require ("incl/pclzip.lib.php");

$newname=$name.".zip";

$zipfile = new PclZip($newname);

 

$v_list = $zipfile->create($name);

 

if ($v_list == 0) {

      die ("Error: " . $zipfile->errorInfo(true));

}

 

header("Content-type: application/octet-stream");

header("Content-disposition: attachment; filename=$newname");

readfile($newname);

//this is to delete the modified file and the zipped  one after being downloaded

unlink($name);

unlink($newname);

print "done";

?>

------------

can you help make those zip files come with names without numbering and i saw this idea in a subtitle site and it works fine.

Link to comment
Share on other sites

It sounds like your browser is doing that to prevent the new file you are downloading from overwriting an already existing one in the target location (downloads folder or wherever your default download location is).  You can change your own browser settings but you can't code it to not do that in browsers in general.  Only way to prevent it is to have it create a unique zip file name every time (like, based on timestamp or something).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.