drupal 7 error when uploading with new field - drupal

I've got a very strange problem using drupal 7. I've got a wbesite running and using views and content types I have been able to build a lot of functionality. Now the following occurs:
When I add a new field to a content type (new or existing) of the the type file or image, I have this field in the form but when I try to upload a file or image using this form it gives an error "The file could not be uploaded" or the full error (from the recent log messages): "The upload directory public:// for the file field field_katapult_voorpagina could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled."
Strangely, when I upload a file or image using an older existing field (pointing to the same directory: public://) it does not give an error and the files upload without a problem. So this makes me think that the server settings are actually set properly.
Anybody who can help me with this problem?
If not, can anybody point me in the right direction as to where I can find the files that handle the upload process in drupal 7?
Many thanks in advance!

You need to check a couple of things :
where is your public files folder, and if that is writable by the webserver ( in /admin/config/media/file-system )
where does your working field send files (it might be a different directory), and if it is, use that for the new fields as well.

Check you file destination directory setting of new image field. Do not include preceding or trailing slashes. This field supports tokens.
You can also check max, min resolutions, file upload limit, image style (if it is new image style other than thumbnail/ or existing) & number of values ( if it set to 1 you can't upload 2 or more). Finally you have to set it public files type.

I think you should check the files folder permission.

Related

Wordpress error "Could not insert attachment into the database" when uploading files

After working on the website without issue for the afternoon, I am suddenly presented with a "Could not insert attachment into the database." error any time I try to upload any files. The size and type of file does not seem to matter.
I have checked permissions and the file upload size and memory limits in WordPress and don't see an issue there. No changes were made between the last successful upload and uploads failing (only a matter of minutes).
I have found that the files are uploading correctly to the file system but are not available within WordPress.
This is likely a MySQL database issue. To find the exact error that's preventing you from uploading media, you can turn on wordpress debug logging by adding define('WP_DEBUG_LOG', true); to your wp-config.php file, then re-create the error, and find the full error message in the debug.log file inside wp-content folder (more detailed instructions can be found here).
In my case, the error was a duplicated primary key when trying to insert into the mac_posts table. The images were actually uploading to the wp-content/uploads folder on the server just fine, but wordpress makes an entry in the mac_posts table for every media item uploaded so it can display it in the wordpress media library. Looking in the database table using phpMyAdmin, the row with the existing ID was a wpforms contact form, so I just deleted that row from the table, re-created the contact form manually, and that fixed the table and the upload issue.
Encountered the same error, figured out it was the length of the image name. Fixed it by renaming to shorter name.

Unable to delete uploaded XML file on Drupal 8.5

I have created a media type that accepts XML files and saves them to a custom publicly accessible location on the server.
Ideally I would like the file to be overwritten when the exact same file is uploaded. This does not happen, instead it creates a new file and adds a number on the end. I have "Create new Revision" turned off.
To get around this issue I thought I could just delete the file via the CMS. The uploaded file has status of "Permanent" and is used 0 places. I know the cron job cleans up files for you, but when I run the cron the file in question is still there. I figure it's because the file is set to permanent, but I don't see a way to flip this to temporary.
Any help is much appeciated.
There is a setting nested away in the file system settings, which lets you configure it to remove (or not removed) orphaned files. If drush isn't removing them despite having no usages recorded, I'd check this option isn't ticked.
The temporary and permanent status are used for storing temporary files during the upload/save process, so I wouldn't tinker with those too much.
If you fancy making the form yourself using the form API, then you can save the file programmatically using the FILE_EXISTS_REPLACE parameter.
https://api.drupal.org/api/drupal/core%21modules%21file%21file.module/function/file_save_data/8.5.x

The file could not be saved Drupal

uploading images from desktop is fine but the problem is when i need to upload image from
mobile browser give me that error
the file 14343254.jpg could not be saved . an unknown error has occurred
the file in the Photo field was unable to be uploaded
photo field is required
I suggest you to use the devel module for that and in hook_file_presave($file) you should use dpm($file) to test if you get the file object. Try it like this:
function MYMODULE_file_presave($file){
dpm($file);
}
If file_presave doesn't work try the hook_file_insert($file).
Both will run if you press the upload button next to the file field or just hit the save button on node edit/add page and will output the file you uploaded to the screen as an object. If you don't have the devel module get it from here: http://drupal.org/project/devel or if you have drush drush dl devel. Try to check the server error log or the recent messages in drupal at Reports. You may have a duplicate entry for the file uri in the database. Check if you modify the uploaded files in one of your custom modules. I hope it helps you a bit.
i finally solved my problem after 1 week of searching
The problem is i am using aws ec2 server with 8GB volume and its 70% filled so images from mobile camera is large its generate unknown error so when i increase my volume to 50GB the problem is solved

Get file path & filename with asp:FileUpload, don't want file... just path and name

I am developing a .NET intranet site which will enable the user to see a list of files (file details stored in DB) and link to the actual PDF/XML/XLS and open it... kind of like a table of contents for the network.
During data entry, the user enters various data about a document, then browses to the file on the network and selects it using the asp:FileUpload. The codebehind then saves the network path to the DB. There is alot of overhead here because i'm sending the file to the server but never use it.
Everything has been working fine until someone tries to use a large PDF file then I get the dreaded MAXIMUM REQUEST LENGTH EXCEEDED error... So I'm trying to find a solution here... I do not need the actual file.. just the path and filename.
I know not all browsers send the full path but our systems have older browsers so everything is working fine now, but will probably break soon.. which is another reason to find a different solution.
I've looked into Javascript to pull the path but that won't work...
Any other ideas? Other ways to just grab the path and filename? (besides manually typing it in to a Text field)
Thanks,
Todd.
This may help too
How to get the full path of a file from asp: file upload?
string filename = Path.GetFileName(FileUpload1.FileName);//file name
string path= Server.MapPath(filename);//path

where does drupal save images when you use cck and imagecache?

I am thinking in moving all JS and images from webserver to another server to mitigate the load on my webserver. then i will use parallel module to get this stuff from the other server.
now, currently i am using cck and imagecache modules. and i dont know where does drupal save the images.
i checked mysql (files table) and found something like this
Mysql>select filepath from files limit 2;
sites/default/files/2010413132344592734_2.jpg
sites/default/files/2010491910913580_5.jpg
i checked for such files but i didnt find anything like this in this directory!!
i inspected one of the images in one of my articles and found that this image is in one of the cache folders that have been generated automatically by imagecache module. i tried to delete this image from server and refreshed my page, imagecache recreated it.
now where did imagecach get this image from? where does drupal save my images??
Thanks for your help
Imagecache takes source images from whatever path is set in the files table, which is generally sites/default/files, the directory you listed. Your imagecache directory was within that directory, right? I think your files are probably in that directory and you just missed them for some reason. Directory listing cached in your FTP client, maybe?
For myself, it stores everything in the sites/default/files folder.
But, some settings to look at...
The File system path setting, located at ?q=admin/settings/file-system
The path settings for the particular field. Open the settings for the particular field, and look in the File path setting in the Path Settings fieldset.
If those settings are different, your file may be somewhere else. Otherwise, it's going to be in your sites/default/files folder.
Check the following locations
[...]\htdocs\drupal\sites\default\files\field\image
[...]\htdocs\drupal\sites\default\files\styles\large\public\field\image
[...]\htdocs\drupal\sites\default\files\styles\medium\public\field\image
[...]\htdocs\drupal\sites\default\files\styles\thumbnail\public\field\image
where [...] is the location of the htdocs folder inside your webserver container.
If you are using xampp then it could be C:\xampp183\htdocs............
Hope this helps !
In the drupal database, check the table "file_managed" and the column "uri" (which gives the uri to access the file either local or remote).
You might find a value like below .. (ignore the jpg name , that is only for my setup)
public://field/image/8_mayurkotlikar_tigress5.jpg
This shows the location of the image.

Resources