Check if image exists (also after deployment) [Solved]

Status
Not open for further replies.

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
JavaScript:
pictureExists = function(filename) { // filename must include file extension.
    const fs = require ("fs");
    return fs.existsSync("./img/pictures" + filename);
};

See also here.

The code above works in the editor but after deploying my project, it always returns false. How do I make this work for both cases (on all platforms)?
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
3,193
Reaction score
1,189
First Language
Dutch
Primarily Uses
RMMV
maybe an "if statement"

if {!filename}
throw new error
else return true ?

that might be the most logic idea though, but idk the most efficient way.
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
Filename checking is not required because the ImageManager does this internally.
I need to check if the image exists on disk.
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
When deployed, the pictures folder is no longer one branch from the launcher but at /www/img/pictures/. You might wanna look at what I posted here, it works both in the editor and when deployed:
You can use the plugin or if you want copy the bit you need :')
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,608
Reaction score
14,331
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Hey everyone, we know that the edit bar is missing. We're working on it. You can talk about it in the announcement here: https://forums.rpgmakerweb.com/index.php?threads/forum-errors-missing-edit-bar-etc.132715/
So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...
Are we now stuck with WYSIWYG ? I cannot revert back my posts to good old raw text ?
I'm wondering if I may be putting too many things into one map. A story, within a story, within a story . . . it's fun, but I can't shake the feeling that it may be better to scrap some of it, and use it for another map. I'm not sure what to do.

Forum statistics

Threads
107,792
Messages
1,032,234
Members
139,939
Latest member
nachteulen
Top