Images not uploading not showing in grid.

DLJonsson

Well-known member
Ver: 8.3-Lerici,2018-04-11
PHP Version: 7.0.30
Mysql version: 10.1.33-MariaDB
Web server: Apache
Client: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
***********************************************************************************************************

Images are not uploading via the "edit the item" screen.

After pushing the browse button the file appears to load as below it says
Current File arrow1_11.

Also we see "arrow1_11." load into the table.

After that though the image does not appear in the grid view or any display in the forms.

Upload directory as been verified as /home/......../public_html/uploads/ in config.php.

Any suggested would be appreciated.
 

DLJonsson

Well-known member
I adjusted .htaccess - and after could see the images were uploading.

I looked at the datatable and noticed the fields length for the image fields was not long enough for the image field names.
After making the image fields char(25) could see the full name loading.

Now though

When I click view image I get can not be displayed because it contains errors.

for instance...

https://harpercollection.info/index.php?r=1527859312&function=show_file&file_type=image_file&tablename=ArrowHeads&tablename_original=ArrowHeads&file_field_name=Photo1&master_table_name=&is_items_table=0&where_field=id&where_value=1
can not be displayed because it contains errors.

Please advise
 

DLJonsson

Well-known member
As mentioned before
When I click view image I get can not be displayed because it contains errors.

Odd thing is when right click 'view image info' in the browser

I see dimensions and other information ie
Type : JPG
Size : 9.7 KB
Dimensions: 24px × 24px

And of course the items full URL...

https://harpercollection.info/index.php?r=1527861768&function=show_file&file_type=image_file&tablename=ArrowHeads&tablename_original=ArrowHeads&file_field_name=Photo1&master_table_name=&is_items_table=0&where_field=id&where_value=1

So it apparently dadabik can see the file but can not display it.

I've tried images created in both MSPaint and in GIMP the images are attached here and are not corrupt by any indication, and yet they do not display.
 

eugenio

Administrator
Staff member
Hello,
first of all: I suggest not to remove/change the .htaccess you have in the uploads folder otherwise anyone can see your uploaded files just by knowing the URL (without being logged in).

Questions:

1) Are the files actually uploaded? Can you see them in the uploads folder? If yes, can you try to download one of then via ftp and open it to see if it is not corrupted?

2) Is the application publicly available somewhere (without login)?

Best,
 

DLJonsson

Well-known member
1) Are the files actually uploaded? Can you see them in the uploads folder? If yes, can you try to download one of then via ftp and open it to see if it is not corrupted?\

Yes, all of the files are uploaded. Can be downloaded and viewed in infraview w/o error or issue.
they are all small jpg files.


2) Is the application publicly available somewhere (without login)?

No, login is required for access. This site is for internal use by a small team of people only,
at least for the foreseeable future.
 

eugenio

Administrator
Staff member
It's difficult to understand where the issue is without seeing the application, but the very first thing you should check is: have you modified the dadabik code (apart from config.php)? When you edited config.php, did you add any extra new line or blank space somewhere?

Please post somewhere a screenshot of the error screen.

Best,
 

DLJonsson

Well-known member
Comparing backup file to current config.php I see in Notepad pluss


TMD set the database name and user.
I set the upload folder location.
Debug has been set to one

Otherwise no change has been made to config.php

Image link below

723mk2ggd
 

DLJonsson

Well-known member
Chrome simply returns a blank black screen w/ a small white square in the middle.
The image in the above message is using firefox.
 

DLJonsson

Well-known member
NOTE the jpg file is loaded to upload folder, and the correct file name is being stored in the photo image field.

I've temporarily opened rights on the uploads folder so you can see the photo here.

http://harpercollection.info/uploads/arrow1_1.jpg

somehow the URL

https://harpercollection.info/index.php?r=1527892356&function=show_file&file_type=image_file&tablename=aw_main&tablename_original=aw_main&file_field_name=photo1&master_table_name=&is_items_table=0&where_field=id&where_value=1

is not mapping to

http://harpercollection.info/uploads/arrow1_1.jpg

Some suspects in config.php

$host = 'localhost';
$site_path = '';

Any suggestions appreciated.
 

DLJonsson

Well-known member
I keep trying to get at the bottom of this.
It appears $upload_directory in config.php has no effect on displaying images,
and that instead $upload_relative_url is used in the process.

This is evident by looking at error_log.
[01-Jun-2018 14:48:03 Europe/Rome]
PHP Warning:
readfile(uploads/arrow1_11.):
failed to open stream:
No such file or directory in
/home/harperco/public_html/index.php on line 1010

Even if though we extend $upload_relative_url
from
$upload_relative_url = 'uploads/'
to
$upload_relative_url = '/home/harperco/public_html/uploads/'

The image still does not display.

We can verify this path by placing
error_log($upload_relative_url.$row[0]);
in index.php on line 1011

...which produces and verifies the path is in fact now correct.
[02-Jun-2018 11:45:39 Europe/Rome] /home/harperco/public_html/uploads/arrow1_1.jpg

readfile($upload_relative_url.$row[0])
apparently is doing something that persistently does not display the image even if the path of the image is fully verified,
and if the image is tested, as browser compatible.
I've tested gif, png, and jpg all with the same results.

Always returning a screen that says

The image https://harpercollection.info/index.php?r=1527892356&function=show_file&file_type=image_file&tablename=aw_main&tablename_original=aw_main&file_field_name=photo1&master_table_name=&is_items_table=0&where_field=id&where_value=1
can not be displayed because it contains errors.
 

DLJonsson

Well-known member
I'm now able to reproduce the error in PHP with a simple php page independent of Dadabik.

https://harpercollection.info/imagetest.php

No adjustment of the header so far makes a difference.

Not sure what the fix is yet. -- any suggestions?


**************************************************************************************************************************************
// imagetest.php

<?php
$file = '/home/harperco/public_html/uploads/arrow1_1.jpg';

if (file_exists($file)) {
// header('Content-Description: File Transfer');
header('Content-type: image/jpeg');
// header('Content-Type: application/octet-stream');
// header('Content-Disposition: attachment; filename="'.basename($file).'"');
// header('Expires: 0');
// header('Cache-Control: must-revalidate');
// header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
?>
 

DLJonsson

Well-known member
This PHP will display the file correctly.
Yet when I attempt to place an analogous patch into index.php it does not work.
It appears to be a problem with PHP's readfile()

<?php
$file = '/home/harperco/public_html/uploads/arrow1_1.jpg';
$getInfo = getimagesize($file);
header('Content-type: ' . $getInfo['mime']);
ob_clean();
flush();
readfile($file);
?>
 

eugenio

Administrator
Staff member
Hello,
$upload_directory is used during the upload process.

I am not sure about your last result, the two versions of the file seem different (content type, content length headers). Are you able to replicate the issue with a file external to dadabik having the same code you see in DaDaBIK's index.php? If yes, please send the PHP file (don't change anything before sending) and the image file and we'll have a look.

Best,
 

DLJonsson

Well-known member
Yes, I'm able to replicate it outside of dadabik

Here is the link.

https://harpercollection.info/imagetest.php

Here is the code.

<?php
$file = '/home/harperco/public_html/uploads/arrow1_1.jpg';

if (file_exists($file)) {
// header('Content-Description: File Transfer');
header('Content-type: image/jpeg');
// header('Content-Type: application/octet-stream');
// header('Content-Disposition: attachment; filename="'.basename($file).'"');
// header('Expires: 0');
// header('Cache-Control: must-revalidate');
// header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
?>
 

eugenio

Administrator
Staff member
Hello,
you have to send the PHP file (don't change anything before sending, please send exactly the same file that is producing the issue, don't copy and paste in another file, it's important) and the image file to support@dadabik.org (I forgot to say that in my previous post).

Best,
 

DLJonsson

Well-known member
* It is impossible to reset header information on the server via PHP.

I tried running this simple script.

<?php
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n";
}
?>

The header returns a corrupted header from 5 days ago for a file that no longer exists.

When I attempt to populate a header using functions such as

$file = '/home/[mysite]/public_html/uploads/arrow1_1.jpg';
$getInfo = getimagesize($file);
header('Content-type: ' . $getInfo['mime']);
readfile($file)

The server returns an error.

This appears to me to be something stuck in apache or in a server's buffer somehow.

Since we use a shared web acccount I can't reboot the server instance which would likely fix this instantly.

I'm waiting response from TMD who so far havn't been able to find a solution.

The solution may be a VPN or Dedicated server we can reboot in such cases.

Thanks Dadabik crew for all your help with this I know it is a peculiar and outlier issue, and your replies
and suggestions have been much appreciated.
 

DLJonsson

Well-known member
This shared LAMP instance has a header buffer problem, as tested outside of Dadabik.

Until we migrate to a dedicated server or VPN, that gives me more control over PHP & Apache I'll need to use the following workaround.

ob_start();
readfile($upload_relative_url.$filename);
ob_end_flush();
 
Top