Такая задача. Открывается окно, там есть <input type="file"> и <input type="text"> и кнопка( Добавить). Когда пользователь выбрал фото, ввел текст и нажимает кнопку (Добавить) должно загрузиться превью картинки на соседнем блоке <DIV> и когда отправиться основная форма, через submit <input type="submit"> то картинка и текст должен записаться БД. 
 
Нашел такой скрипт который после выбора картинки из <input type="file">   выводит превью картинки. Может как то можно изменить и доделать ?
<style>
	  .thumb {
	    width: 400px;
	  }
	</style>
<input name="filename" type="file" id="files"><br>
	<output id="list"></output><br>
function handleFileSelect(evt) {
    var files = evt.target.files; // FileList object
    // Loop through the FileList and render image files as thumbnails.
    for (var i = 0, f; f = files[i]; i++) {
      // Only process image files.
      if (!f.type.match('image.*')) {
        continue;
      }
      var reader = new FileReader();
      // Closure to capture the file information.
      reader.onload = (function(theFile) {
        return function(e) {
          // Render thumbnail.
          var span = document.createElement('span');
          span.innerHTML = ['<img class="thumb" src="', e.target.result,
                            '" title="', escape(theFile.name), '"/>'].join('');
          document.getElementById('list').insertBefore(span, null);
        };
      })(f);
      // Read in the image file as a data URL.
      reader.readAsDataURL(f);
    }
  }
  document.getElementById('files').addEventListener('change', handleFileSelect, false);