Move somes images from assets

hi everyone!

when i want to move some images from the assets to a directory like images, the website says “To add this file, you’ll need to save it to your computer first”.

but, i don’t know what he means. can anyone help me?

Hey @samzan,

It means that images to be uploaded in the assets can be loaded only from the computer and not from links. To move images from assets to a folder (or directory) like images, here’s how to do it:

  1. Go to the assets folder in your project and select the image you want to upload locally to your Glitch project. Click on the ‘copy url’ button. This will copy an image url like to your clipboard.

  2. Create a new assets folder by typing mkdir assets and hit enter.

  3. type cd assets and hit enter to move into the assets folder

  4. type wget and then paste the image url you copied previously into the console, so you
    see something like wget and hit enter. That’ll import that image to your assets folder. Note that it’ll be imported with the name (the random bunch of letters and number in the image URL after the part) 68ece3d5-980b-4d94-b09a-6ea0770ea2cf%2Fdonut_white.png?v=1572257738465 . To make it easier to deal with you’ll want to rename it. To do so, type mv /app/assets/68ece3d5-980b-4d94-b09a-6ea0770ea2cf%2Fdonut_white.png?v=1572257738465 /app/assets/donut_white.png and hit enter.

  5. Type refresh in the console to update your project directory and the new assets folder shows up in the project.

  6. Repeat steps 1 and 5 for each image you want to upload. Be sure to change the name of the file to the relevant one in step 4.

To call the file in your script, you’ll need to use the path: __dirname + '/assets/donut_white.png'

Note that the donut_white.png is just an example.

1 Like