Midnight Voices (https://www.peteatkin.com/cgi-bin/mv/YaBB.cgi)
Atkin admin >> Tech >> Image upload changes
(Message started by: S J Birkill on Today at 06:56)

Title: Image upload changes
Post by S J Birkill on Today at 06:56
Member Black Funk Rex recently (see this thread (https://peteatkin.com/forum?board=tech&action=display&num=1684544343&start=0#0)) pointed out a problem the site had with audio-streaming files restricted to MV members. This was the result of a host-wide upgrade to the version of PHP (a server-side program) used. Thanks to BFR we modified the code and restored full functionality.

But Black (if I may call him that) also drew my attention to an issue with our user-image upload facility, used for members' personal avatar images as well as images they may wish to include in their posts. This is not related to the PHP upgrade.

Without going into too much detail, a URL (Internet page address) is by design restricted to a limited set of 'valid' or 'legal' characters, basically ASCII alphanumerics and certain punctuations. Try to include anything else and you will break the link, or (in the case of so-called 'reserved' characters) cause it to do something you didn't intend.

File names (in Windows at least) can include a much wider range of characters without flinching. The problem comes when we attempt to include a Windows filename in a page address. Deviation from the legitimate characters will usually cause the link to fail.

In MV usage, the most frequently-used 'forbidden' character is the space. We use it all the time -- it makes the filenames more readable. In designing the code to generate a URL for a member's uploaded image, I originally pointed the link to the directory on our server where the image is stored, then used the member's original title to identify the particular file containing the image. But if that title contains a space, it doesn't work: it's not allowed as part of a URL.

The recommended method of avoiding this is to encode all 'forbidden' characters in the putative URL string using so-called "percent coding", whereby each is escaped -- replaced by a code such as "%20" (in this case the code for "space"). But a URL containing such codes can be difficult for the user to read, defeating somewhat the principle of using the original file name.

I could request that, when uploading a file, the member changes the file name, replacing each space (where there are any) with a different, valid character, such as the underscore ("_"). But that impacts ease of use for a non-technical user. So instead, as a workaround for the moment, I've arranged for this substitution to be done automatically at the server when the file is uploaded. This should avoid such difficulties for the vast majority of users' filenames, while retaining the desired ease of use.

That's where we stand at present.

So if you've encountered problems in the past when uploading an image for your avatar, or for inclusion in a post -- perhaps the image didn't appear after upload, or you received an error message -- you might like to try again. Proceed just as before, as instructed on the "post" page; you don't need to change the filename. All being well it will now work as intended.

Steve



Midnight Voices » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.