Trusten Posted February 6, 2003 Posted February 6, 2003 Ok. I'm trying to make a mod that will allow people to upload files to the site. blah blah blah. sorta like the contribution form that's here. but it's going to be interegrated into the store so that people can search for the files. well, um, that's the plan *cough*. The problem of course arises with the name of the file. Osc has a tendency to overwrite files of the same name. Is there any way that I can make a modification that will attach itself to the file name. like with the product ID. like, if the file is testfile.zip once it is trying to save itself to the site, it is called 67testfile.zip and 67 would be the product id. is there any way i can do that? overall, is there any thing i can do? it will be using the admin type area. Since that area is chalked full of all the codes. any help will be apreciated....
Rumble Posted February 6, 2003 Posted February 6, 2003 Only a suggestion not a solution; Instead of attaching the product id to it why not make it completely unique by adding the date and time code to it like the back up does in the admin section. therefore testfile.zip would be uploaded to something like testfile20030206121635.zip where the number is yyyymmddhhmmss Looks ugly but would be less likely to get duplicate files. You would need to take a look at the 'backup.php' file in the admin folder to lead you in the right direction. Wish i could help you further but hopefully someone with better php coding knowledge could take this further. Good luck. Reddy to Rumble Reddy to Rumble Thank you osCommerce and all who Contribute to her!
Trusten Posted February 6, 2003 Author Posted February 6, 2003 very good idea! um, COULD you help me further please??? it's hard enough as it is. :cry:
mattice Posted February 6, 2003 Posted February 6, 2003 // we have an incoming file (temp.zip) in $file // create stamp $now = date("m-d-Y_H.i.s"); // merge $stamped_file = $now . '-' . $file; // rename rename("/tmp/$file", "/home/yoursite/downloads/$stamped_file"); Outcome would now be something like 02-05-2003_15.32.22-temp.zip Mattice "Politics is the art of preventing people from taking part in affairs which properly concern them"
Trusten Posted February 7, 2003 Author Posted February 7, 2003 mattice, what file is that code located in?
mattice Posted February 11, 2003 Posted February 11, 2003 I just wrote that from scratch :) It's not in any osC file, you'll have to implement it manually in wherever you need it. Mattice "Politics is the art of preventing people from taking part in affairs which properly concern them"
Recommended Posts
Archived
This topic is now archived and is closed to further replies.