filefield

Save a file using a model and non-model-based Form in Django

I have a model with a FileField and a form that has a FileField as well. The form is not a ModelForm based on the model but it's a regular Form. How do I save the uploaded file from the form to the model? ...

Drupal Filefield won't upload javascript files?

Hiya, I've got a site where individual pages might require some javascript or CSS files hooked into their heads. I'm trying to keep everything client side when it comes to managing this process, rather than getting on the FTP and sorting everything out in the code so I need to be able to upload css and js files. I've got CCK filefield...

Django ImageField / FileField custom upload_to function, and security

Hi. I have part of a model defined like this: logo_image = models.ImageField(upload_to=lambda i, fn: "logo_%s"%(fn), height_field="logo_image_height", width_field="logo_image_width") and had a question about the upload_to function. According to django's documentation for FileField.upload_to, the second paramater, filename is "The fil...

Saving nodes with a filefield

I'm in the progress of creating a bulk upload function for a Drupal site. Using flash I'm able to upload the files to a specific url that then handles the files. What I want to do, is not just to upload the files, but create a node of a specific type with the file saved to a filefield that has been setup with CCK. Since these are audio f...

Drupal 5 FileField not attaching files

I recently inherited a Drupal 5 site, and I'm having some trouble with the FileField module. I click Browse, find my file, then click upload. The file is an .mp3, which is a valid file extension, and is about 5MB. It looks like it's uploading it, but then it finishes and nothing is there. Here are the things I checked: * I checked my ...

Django - update a model won't delete the old FileField

Hello! I am implementing an application with django, which has a model with a FileField: class Slideshow(models.Model): name = models.CharField(max_length=30,unique=True) thumbnail = models.FileField(max_length=1000,upload_to="images/app/slideshows/thumbnails") and I have an admin backend where django manages the models. I jus...

Validating data in Django ModelForm

And i have a simple modelform for Package from models import Package from django import forms class PackageForm(forms.ModelForm): class Meta: model= Package fields= ['name', 'version', 'url', 'description', 'arch', 'dependancies', 'conflicts', 'file'] How can i ask the modelform to check, within validation, if the file extens...

Django test FileField using test fixtures

I'm trying to build tests for some models that have a FileField. The model looks like this: class SolutionFile(models.Model): ''' A file from a solution. ''' solution = models.ForeignKey(Solution) file = models.FileField(upload_to=make_solution_file_path) I have encountered two problems: When saving data to a fix...

How to localize the label of a file_field in Rails?

I want to localize a form in my app so that all the labels are in Finnish. This is easy with all other form components, but how do I do this with a file field? It always seems to give me a label "choose file" in the button and "no file chosen" immediately after the button. ...

cck remote file (image) field - I want to keep the cached copy of the image when the node is deleted

I use the Remote File module for a cck field displaying a remote image. It works with a known issue: images are reloaded on every edit http://drupal.org/node/395256 And as i do tests with lots of nodes and delete them afterwards, the images cached in filesystem become deleted too. Is there a way to tell filefield(?) not to delete them?...

Drupal creating organic groups using drupal_execute.

Hi, I'm trying to create a node programatically and use the Filefield Module to upload a file from a remote url. The node is being created properly but I can't get the remote url upload working. Anyone have any experience with this? ...

php code for inserting text file into the database

hey i have form which has a file field. After selecting a file,i want to insert the selected file into the database column. how do i do it? ...

Problem with filefield module after migrating drupal site to a new server: cant upload files

We have a content type with two imagefield / filefield fields, and after migrating our site to a new server, we have the following problem: When we submit a new item for this content type, with two images for those fields, drupal gives us the following error and does not upload the images: warning: fopen(sites/default/files/.htacc...

Django: Save an uploaded file to a FileField

I feel a little stupid for having to ask this… But I can't seem find it documented anywhere. If I've got a Model with FileField, how can I stuff an uploaded FILE into that FileField? For example, I'd like to do something like this: class MyModel(Model): file = FileField(...) def handle_post(request, ...): mymodel = MyModel.o...

Django FileField: how to set default value (auto-create empty file)?

I've got a model like this: class MyModel(models.Model): name = models.CharField(max_length=255) code = models.FileField() When a new MyModel is submitted, I want to allow for the code field to be left empty, in which case I need Django to create an empty file (with arbitrary name). Question is: what is the right way to do it...

How to assign a local file to the FileField in Django?

I was trying to assign a file from my disk to the FileField, but I have this error: AttributeError: 'str' object has no attribute 'open' My python code: pdfImage = FileSaver() pdfImage.myfile.save('new', open('mytest.pdf').read()) and my models.py class FileSaver(models.Model): myfile = models.FileField(upload_to="files/") ...

AttributeError: 'file' object has no attribute 'open' in Django while assigning a local file to the FileField

Possible Duplicate: How to assign a local file to the FileField in Django? I was trying to assign a file from my disk to the FileField, but I have this error: AttributeError: 'file' object has no attribute 'open' My python code: pdfImage = FileSaver() myPdfFile = open('mytest.pdf') pdfImage.myfile.save('new', myPdfFile) a...

passing a callback as upload_to to FileField

I have an abstract model class UploadItem for handling uploaded files. I want each subclass to be able to define the upload_to path. For this, i pass a callback to the constructor of FileField. This is an example: class UploadItem(models.Model): file = models.FileField(upload_to=UploadItem.get_directory) class Meta: ...

Imagefield Crop – use existing file

Is there a way to make a few images with Image Crop out of one uploaded file? Currently i have to upload the same, big pic to get new pics with various dimensions. Unfortunately the "Imagefield sources"-module doesn´t support Image Crop. Is there an alternative? ...

Drupal Filefield Source install question

Filefield Source is a module which works with CCK and Filefield which allows users to select files from already uploaded files, instead of having them upload a file multiple times. I installed the module, but cannot see it. I am using CCK version 2.8 and Filefield version 3.7. Any guidance would be appreciated. Probably just some stu...