[Skip to main content](#vessel-content)

#   How to delete files uploaded but not used

##

- **[OPHWD](/forum/user/58074-ophwd "View OPHWD's Profile")**
- [![OPHWD's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/58074-ophwd "View OPHWD's Profile") Topic Author
- [ Offline](/forum/user/58074-ophwd)

Less More

- Posts: 19
- Thank you received: 0
-
-

7 years 4 months ago [\#308306](#308306) by [OPHWD](/forum/user/58074-ophwd "View OPHWD's Profile")  *[How to delete files uploaded but not used](/forum/23-market-how-to/897805-how-to-delete-files-uploaded-but-not-used#308306 "-- HikaShop version -- : 4.1.0 -- HikaMarket version -- : 3.0.2 -- Joomla version -- : 3.9.5 -- PHP version -- : 7.1 -- Error-message(debug-mod must be tuned on) -- : No error message  On add product process, when a file is uploaded and deleted before save the new product the file remains on server. How to avoid this behavior and delete the file on server when it is deleted on file uploader?")* was created by *[OPHWD](/forum/user/58074-ophwd "View OPHWD's Profile")*

-- HikaShop version -- : 4.1.0
-- HikaMarket version -- : 3.0.2
-- Joomla version -- : 3.9.5
-- PHP version -- : 7.1
-- Error-message(debug-mod must be tuned on) -- : No error message

On add product process, when a file is uploaded and deleted before save the new product the file remains on server. How to avoid this behavior and delete the file on server when it is deleted on file uploader?

- [ ![Selection&#95;235.png](/forum/attachment/47193) ](/forum/attachment/47193 "Selection&#95;235.png") [ ](/forum/attachment/47193?download=1 "Selection&#95;235.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzIzLW1hcmtldC1ob3ctdG8vODk3ODA1LWhvdy10by1kZWxldGUtZmlsZXMtdXBsb2FkZWQtYnV0LW5vdC11c2VkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26400
- Thank you received: 4079
-
- [](http://obsi.dev)
-

7 years 4 months ago -  7 years 4 months ago [\#308342](#308342) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[How to delete files uploaded but not used](/forum/23-market-how-to/897805-how-to-delete-files-uploaded-but-not-used#308342 "-- HikaShop version -- : 4.1.0 -- HikaMarket version -- : 3.0.2 -- Joomla version -- : 3.9.5 -- PHP version -- : 7.1 -- Error-message(debug-mod must be tuned on) -- : No error message  On add product process, when a file is uploaded and deleted before save the new product the file remains on server. How to avoid this behavior and delete the file on server when it is deleted on file uploader?")*

Hello,

The upload behavior when a product is not yet created is a bit tricky and HikaMarket and HikaShop are using the same workflow.
Since you do not have a product ID, the upload is made without a product assignation and it's only when you save the product that the files are then associated with the product just created.

One possible fix would be to perform an ajax call when the file is deleted, so it can be also delete in the server (with all the necessary security checks, obviously).
Another solution would be to use a cron task which will delete "old" non associated files. That part would also handle other kind of upload which can have the same kind of behavior.

The first solution can be implemented into HIkaMarket but it's not a kind of patch that I can do in a short time and give you the patch in the forum. Depending how the other developments are going, it might be something we can add in a future release.

Edit: In the mean time, if you're not using product approval : you can configure your HikaMarket ACL to not authorize the upload for "product/new" but only to "product/edit" ; so your vendors would be able to upload files only when the product already have an ID.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Last edit: 7 years 4 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzIzLW1hcmtldC1ob3ctdG8vODk3ODA1LWhvdy10by1kZWxldGUtZmlsZXMtdXBsb2FkZWQtYnV0LW5vdC11c2VkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[OPHWD](/forum/user/58074-ophwd "View OPHWD's Profile")**
- [![OPHWD's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/58074-ophwd "View OPHWD's Profile") Topic Author
- [ Offline](/forum/user/58074-ophwd)

Less More

- Posts: 19
- Thank you received: 0
-
-

7 years 4 months ago [\#308499](#308499) by [OPHWD](/forum/user/58074-ophwd "View OPHWD's Profile")  Replied by *[OPHWD](/forum/user/58074-ophwd "View OPHWD's Profile")* on topic *[How to delete files uploaded but not used](/forum/23-market-how-to/897805-how-to-delete-files-uploaded-but-not-used#308499 "-- HikaShop version -- : 4.1.0 -- HikaMarket version -- : 3.0.2 -- Joomla version -- : 3.9.5 -- PHP version -- : 7.1 -- Error-message(debug-mod must be tuned on) -- : No error message  On add product process, when a file is uploaded and deleted before save the new product the file remains on server. How to avoid this behavior and delete the file on server when it is deleted on file uploader?")*

Perfect. A lot of thanks for your help I will explore that options to meet this requirement.
Best Regards !!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzIzLW1hcmtldC1ob3ctdG8vODk3ODA1LWhvdy10by1kZWxldGUtZmlsZXMtdXBsb2FkZWQtYnV0LW5vdC11c2VkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

Moderators: [Obsidev](/forum/user/7040-obsidev "View Obsidev's Profile")

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.046 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
