I am trying to setup a scenario where a user might be uploading multiple files (although 1 at a time). For some reason, I am not able to figure out how to accomplish this. I have added field elements to my form that allow single file uploads. As a user, I can easily get to uploading 1 file and then previewing it. But when I go to add another file, the previous file still shows as being uploaded and if I try to replace it with another one, it says the new file will delete the old one and I also get a DB error -
user warning: Incorrect integer value: '' for column 'weight' at row 1 query: UPDATE upapi_data SET description='B_First Image.jpg', weight='', fid=2, obj_id=0, obj_type='node', label='mri_upload' WHERE upapi_id=2 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal\includes\database.mysqli.inc on line 151.
Any pointers?
Thanks!
Comments
Comment #1
Dave Cohen commentedClearly, the 'weight' used to sort multiple files is not being set. So there is a bug to track down.
Can you reproduce this problem using the upload_example.module?
Can you post your form element here?
Comment #2
achatter commentedI just now tried the upAPI example by adding two stories to the nodes and I didn't get the error. I also didn't get the scenario where while creating a new Story, the old file was showing up. Obviously, I have not created my upfield elements correctly. I have pasted a section of my module that has the upfield elements - if it doesn't make sense, I will attach the module.
And here is the code for the nodeapi -
I really appreciate you looking into this for me. I have been struggling to get this to work!
Thanks.
Arindam.
Comment #3
achatter commentedI copied over the upapi_example files and it seems to have fixed that issue. I can now upload a new file everytime a new node is created.
The last bit of problem I am facing is showing a link to the file so it can be pulled up from the location where it is stored. In my upfield element I am uploading a file to a different location than the upapi_example. When I get the link back after the file is uploaded, I get a "Access Denied" message. I am not able to follow how the link is getting set. When I look at the link it is something like - http://locahost/drupal/?q=upapi/download/i where i is a number. It works in the Story node when I upload a file, and I can click on the link created and it pulls up the file using the upapi_example module, but not from my node/module. I am tearing my hair over this!!! Must be something simple I am overlooking.
Any advice?
Thanks.
Comment #4
achatter commentedI was not assigning rights for download to the particular labels that were getting the file uploads. Once done as described in upapi_example, everything was fixed and it works like a charm!
So in detail -
$file->label needs to have your file labels set to allow download and viewing of the files/images etc.
Thanks for the wonderful module. It has been very helpful.