I have a WordPress site. There are user levels (0.Basic, 1.Contributor, 2.Researcher, 3.Editor, 4.Admin).
I have data in excel documents. What i need is lvl 2+ registered Users , can edit and add their data to an excel document with out editing the previous data. Now the Admin need to take a notification for that change (Example , username added some data to that file) , see the changes and update or delete the current excel file.
For now the only think im thinking of is that the user sends an excel file via a form upload to the admin and then the admin manually can do the changes.
I wanna know how i can do this cause later on i need to plot those data in charts in specific pages.
Thnx a lot.
Related
I'm trying to create a front-end AJAX file uploader for a form and everything is working perfect, except for one issue.
I used deferred binding to enable uploading before the record is created in DB.
In a rare scenario, when someone uploads a file and doesn't send the form the record is not created, but the attached file still exists.
I don't know if there is a build-in solution for this problem is October CMS.
A better example is RainLab Blog Plugin. If you try a new post and add a featured image but not save the post and close the tab, the post doesn't create but the file remains in storage/app/uploads/public.
I was thinking of writing an scheduled task to delete unbinded files, but don't know how to detect them.
Does anyone have a solution for this issue?
you can look at the table:
system_files
and the ones without a
attachment_id or/and
attachment_type or/and
field
are unused maybe the media table should be cleaned too.
i'm trying to make vacancies plugin for my website (corporate website where users can submit their job offer application).
What i am trying to achieve:
User goes to specified page
User uploads file with regard to the provided guidelines
Script saves file in the specified folder and gets name of the file as the name of the applicant
Script adds information to database (id, applicant_name, file_path, created_on, updated_on)
Admin can view application in the backend
I've managed to achieve first 4 goals, however i have no idea on how to allow administrator to get the link to the file from the backend.
I'm using models to store information in the database. On the backend i can see when the file is uploaded and what is the name of the applicant. However, what im trying to do is when administrator clicks on the item in the list (model default update page), he should be prompted with the link to download file.
Here are few screenshots:
Form to send the CV
Backend View
Here administrator should be able to get the link to download file (maybe, later i will do integration with Office Online Document Viewer)
Database view after file has been submitted
Anyone have an idea on how to provide such functionality to the administrator?
Maybe, to simplify question even more, i will put it this way:
How can i get Model object in the update.htm in the controller file, so i can access all of the fields of the model from this file. Right now it uses
$this->renderForm();
Suppose we have the web application which handle create, read, update and delete articles and each article should have gallery of images. I have to make one to one relation between Article and Gallery and one to many relation between Gallery and Media.
HTML5 gives a lot of features like multiupload, so I want to use this excellent http://blueimp.github.io/jQuery-File-Upload/ plugin for that. The problem is how to handle the file upload "in memory" like other form's data?
For example when we show the page for create new article we should be able to fill in article's data fields and select images to upload, next when we click the save button the images should start upload and after that the form should submit. When validation fails the images should be still displayed on the frontend, but on the server-side nothink should be saved.
One of the solutions is create somethink like "create entity session temporary id" before displaying the entire form and that id can be used to create temporary directory for save uploads, so after success saved form these images can be moved to appropriate directory, but how to make the "create entity session temporary id"?
The other solution I think is the "with the edit id" approach, because we can handle the uploads with previously saved gallery id, but sometimes I can't save new blank article with gallery, cause some of the fields should't be empty in db.
For the Rails I saw https://github.com/thoughtbot/paperclip gem which in the Readme says:
Paperclip is intended as an easy file attachment library for Active Record. The intent behind it was to keep setup as easy as possible and to treat files as much like other attributes as possible. This means they aren't saved to their final locations on disk, nor are they deleted if set to nil, until ActiveRecord::Base#save is called.
My question is how it works?
The problem with enabling file uploads on the create mask is that you eventually end up with orphaned files. This is because a user is able to trigger the upload without saving the actual entity. While creating a very own UploadBundle I thought about this problem for a while and came to the conclusion that there is no truly proper solution.
I ended up implementing it like this:
Given the fact that our problem arise from orphaned files, I created an Orphanage which is in charge of managing these files. Uploaded files will first be stored in a separate directory, along with the session_id. This helps distinguishing files across different users. After submitting the form to create the actual entity, you can retrieve the files from the orphanage by using only your session id. If the form was valid you can move the files from the temporary orphanage directory to the final destination of your files.
This method has some pitfalls:
The orphanage directory itself should be cleaned on a regular basis using a cron job or the like.
If a user will upload files and choose not to submit the form, but instead start over with a new form, the newly uploaded files are going to be moved in the same directory. Therefore you will get both the files uploaded the first time and the second time after getting the uploaded files.
This is not the ultimate solution to this problem but more of a workaround. It is in my opinion however cleaner than using temporary entities or session based storage systems.
The mentioned bundle is available on Github and supports both Orphanage and the jQuery File Uploader plugin.
1up-lab/OneupUploaderBundle
I haven't work with the case personaly, but my co-worker had similar conundrum. She used
punkave/symfony2-file-uploader-bundle
It's a bundle that wrapps jQuery File Upload plugin. It is in the early stages and a lot of things are missing, such as event, but we gave it a shot.
That's what we do: in newAction() we create entity, generate unique dir ID, and store the ID in entity (via regular setDirId()). Than we create the form, which contains hidden field dirId.
We are uploading the files to temp dir on server via ajax, not during the submit. Ajax request requires the ID. It stores files in temp_dir/prefix_ID
Than it's quite simple. Form is sent. If form is valid - move files from temp to dest dir. If not - we have the ID, and are able to show the images.
However, we do not save information about individual files in a separate table in the database. Every time we read the contents of the folder that corresponds to our dirId.
I know it's not the solution You are asking for. It's rather a workaround.
I am working on a migration work to WordPress for a site where all user images of old site has to set as avatars in WordPress buddypress profile.
I wrote a PHP script to migrate all users along with passwords and working fine.
My problem is how to set user avatar using PHP code (not WordPress code). I didn't understand how it is storing and where in tables it is storing. I know the location it is storing be in format like,
wp_content/uploads/avatars/userid/randomtext.jpg
How this randomtext.jpg is generating and where this information is saving?
Can anyone help me?
Thats it you dont have to create any random text. Just create a directory with userid as name in inside "avatars" folder and save two images like say for userid (22),
wp_content/uploads/avatars/22/22-bpfull.jpg (150x150px)
wp_content/uploads/avatars/22/22-bpthumb.jpg (50x50px)
or
wp_content/uploads/avatars/22/anyname-bpfull.jpg
wp_content/uploads/avatars/22/anyname-bpthumb.jpg
Thats it. No need to store in any table. Just create images in respective directories.
All,
I have a PHP5 application written with Zend Framework and MVC style. My application allows multiple users to login and see content based on their privileges. I have a dropdown on the home page. Upon selecting the dropdown, an ajax call occurs which populates the page with a table. Also, it generates a PDF file with the table data using mpdf library. There is a link called "Download PDF" in the page to allow the user to download the generated pdf.
My question is, in such environment, how to best serve pdfs to multiple users? Should I serve a single pdf with the a common name or should I create multple pdfs based on the dropdown value (looks like an overkill)? I don't want to let the users see each other's pdfs. Also, where should I store the pdfs as pretty much the entire application directory will have only 750 acccess.
Thanks,
User clicks "downlod PDF"
Parameters like ID are sent with ajax
Is there a cached version of the PDF with that ID saved? Ok, show it to the user; else:
Generate PDF
Cache it
Show PDF to user
I would have a cache key like userid-documentid (user1-document1 for example) and name the document something that would make them recognize it in a "downloads folder": your-app document-name date.pdf (ABC Half year report 2010-07.pdf for example).
I would store the cache in a /tmp directory somewhere, and present the cached data with a custom header; the following is from Example 1 # php.net:
<?php
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="ABC Half year report 2010-07.pdf"');
readfile('/tmp/user1-document1');