The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
file uploader
#1
hey, thought i'd implement a file uploader, mainly for images but other files too, form uploads image to directory on server, in my case users/uploads/avatar . you can then either save the filename or full file path to the database, in my case i added a row to the
Code:
profiles
table called avatar. here it goes:

the files we need are:

patch-4.2.6-uploads.php - place somewhere so you can navigate to it in the browser within userspice, maybe root
class.upload.php - place in users/classes/
uploads.php - place in users/includes/

patch-4.2.6-uploads.php: navigate to this in browser, it will magically add the required db row to table
Code:
profiles
https://pastebin.com/RXJ9BxTp

class.upload.php: best left untouched
https://pastebin.com/DpKmdXex

uploads.php: adapt to your needs-change things like image types, locations, db insertion etc
https://pastebin.com/iLKrM1J8

Next we need the form: adapt to your needs
https://pastebin.com/ZJ353CHa

heres how the form looks:
https://pasteboard.co/7nRsmlvAa.png

you could go one step further and upload without page refresh using ajax as snippet below, just need a way to refresh the image preview otherwise page refresh is required.
https://pastebin.com/BjDfdare
  Reply


Messages In This Thread
file uploader - by firestorm - 05-17-2017, 12:10 PM
RE: file uploader - by shoropio - 09-21-2018, 09:07 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)