I'm using ms4w and working on my local machine and want to build a map like in the MapServer Example 1.9 (https://mapserver.org/tutorial/section1.html).

Unfortunately the HTML template doens't display the image of the map. The map images are only generated and saved in the tmp folder, but not shown in the browser.

My HTML template index.html looks like this:

    <form name="mapserv" method="GET" action="">
          <input type="hidden" name="program" value="">
          <input type="hidden" name="map" value="C:/MapServer-Project/myMap.map">
          <input type="hidden" name="imgext" value="270353 5135877 931021 6201334">
          <input type="hidden" name="imgxy" value="200 150">
          <input type="hidden" name="zoom" value="0">
          <input type="hidden" name="layer" value="airports">
          <input type="hidden" name="mode" value="browse">
      <div align="center">
        <table border="1" cellpadding="0" cellspacing="0">
            <input type="image" name="img" src=[img] width="400" height="300">

The web definiton in my mapfile myMap.map looks like this:

        TEMPLATE  'index.html'
        IMAGEPATH data/tmp/
        IMAGEURL  tmp

Folder structure:


I think there is a problem with relative paths. I think the img-tag in <input type="image" name="img" src=[img] width="400" height="300"> is not able to find the C:/MapServer-Project/data/tmp folder.

For exmple somehow I can't use /cgi-bin/mapserv.exe for <form name="mapserv" method="GET" action="">. I have to use the prefix. Otherwise the application can't finde the file.

1 Answer 1


MS4W comes ready out-of-the-box with directories properly configured for the generated map images by MapServer (this is why I created MS4W, to prevent issues such as yours). For example, if you check the mapfile that you mention in the MapServer tutorial (available for download from https://mapserver.org/tutorial/background.html ), and open in Notepad++ the mapfile: C:/ms4w/apps/tutorial/htdocs/example1-9.map you can see the proper settings for IMAGEPATH and IMAGEURL, that is used for all MS4W applications:

    IMAGEPATH '/ms4w/tmp/ms_tmp/'
    IMAGEURL  '/ms_tmp/'

It is much easier to follow the exact same structure as the working MS4W applications, and create your project in the apps folder in C:/ms4w/apps/project/mymap.map and use the same settings as mentioned.

Of course since the MapServer tutorial is actually configured for MS4W (by me) you can actually extract the entire tutorial at the root of your drive at C:/ and restart Apache, and then follow the tutorial locally on your machine instead.

hint: if you haven't done it already, be sure to add color styling to mapfiles in your Notepad++ instance through https://ms4w.com/trac/wiki/Notepad++MapServerStyle

Happy mapserving!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.