I have a form that a user uses to upload a CSV file. Right now the user has to type the full file path of the file into a text box. How can I get a browse for file popup to allow the user to navigate to the file instead of having to type the whole path? Is the functionality already present and I just don't know how to use it yet?
you can create your own class with API calls. Here you have the code. Or you can add a reference to Microsoft Office xx Object Library and use the FileDialog class.
Here you have an example of usage.
I prefer the first method, because you are not attached to an external library.
Related
Does anyone know of a PDF printer driver that allows you to programatically set the file name for printing/saving.
Im not sure if its possible with PDFCreator, but Im unable to figure it out.
So I am creating HTML Reports and have a print button to print it to PDF.
But now I have to automate it more so that it will be able to generate the PDF with a certain name. This without human interaction.
Win2PDF has several ways to do this.
The Auto-name feature can automatically name the PDF file, and can use the document title to name the files along with configurable date/time stamps. This can be configured with no changes to your program.
The file name can also be set by your program using the Windows API or by setting a string value in the registry named PDFDefaultFileName.
Similar to the uploading feature in fuelphp (link provided below), is there a tutorial for downloading files in fuelphp. There is not much information out there for fuelphp (other than the docs). Would I require a separate config page called download.php similar to upload.php?
All I really need is a page with either a download link or button to export csv to a user's local machine
Link to Upload feature
https://www.tutorialspoint.com/fuelphp/fuelphp_file_uploading.htm
Thanks in advance
Have you looked at the File class? This has a method of download which you pass the path of the file to. The 2nd param allows you to specify the name of the file that's downloaded.
File::download('path/to/file.txt, 'new-file-name.txt');
If you want to restrict downloads per user, you'll need to add logic around that.
https://fuelphp.com/docs/classes/file/usage.html#/method_download
Example
Create a new controller, as you've pointed out, download.php, and use the following as a starting point.
You'll need to pass something through to the get_index in order to determine which file the client will download. I'd suggest some sort of look up, using an unique identifier, instead of a file path, otherwise this would easily be exploited.
class Controller_Download extends Controller
{
public function get_index()
{
// #todo add logic surrounding file download
File::download('path/to/file.txt, 'new-file-name.txt');
}
}
How can we open a word document or pdf file by clicking on any link in Odoo? What are the steps need to be done?
1) Install module Document Management System (document).
2) Create directory (knowledge menu unit) or use existing one. Attach to this category required file (button "Attachments" above the form)
3) Since it was downloaded, it would generate an url. To access it: mouse right click on downloaded file - save url
4) Add the url to the website. Pressing it will download the file (publically available).
Note : Above Functionlity Work on odoo 8.
Document Management System module Remove in odoo 9 community and enterprice so this all file store in ir.attachment model.
So. Programatically, it is pretty much the same. The module 'document' allows to attach files to any object, including product.product (or product.template). So you have to find it:
attachment_ids = self.env['ir.attachment'].search([('res_model','=','product.product'),('res_id','=',product.id)]).
Where product.id - is id of needed product. E.g. you can store attachment_ids in product.product class as one2many field. After that you can get an url of any attachment. For example, for binary files:
for attach in attachment_ids:
url = 'https://yourcompany.com'+'/web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id='+str(attach.id)
This url may be easily added to the website product site, using foreach in product.attachment_ids
I have a working s3 uploader in actionscript that uses the FileReference class so a user can browse for files to upload when he/she clicks on the upload button.
I have a web application and I want the user to have his/her configuration saved to s3 as an XML file when they hit the save button, so the "save" button will trigger the upload. However, i cant figure out a way to add the XML file to the FileReference variable I create. I was looking at the File class but that appears to be only usable in AIR.
Is it possible to create a FileReference object based off of an XML file that actionscript creates within the application without browsing for a file using FileReference.browse(); ?
Thanks
The answer to my original question is "no". According to this article by Mike Chambers, you cant.
It is apparently a sandbox issue so that a malicious flash program will not be able to do anything related to saving files without a users permission.
I have an XML file located on my desktop that I would like to bind to a dashboard widget list (tableview). Although I am able to bind this file if it's within the widget's bundle folder, I am unable to bind the XML file to the list externally. A modal dialog warning shows: "try entering a path relative to your application"--yet this also does not seem to work. And yes, I made sure to check the "Allow external file access" within the Widget Attributes panel.
I think I have found a solution: instead of using the conventional unix file path for the datasource reference, e.g. '/Desktop/myXMLFile.xml', I find that an XML file also has a URL path: 'file:///~/Desktop/myXMLFile.xml'. Coming from the world of Cocoa programming, I was ignorant of XML files and widget behavior as a web 2.0 kind-of-thing.