Note that there are some explanatory texts on larger screens.

plurals
  1. POError in uploading file in node.js
    primarykey
    data
    text
    <p>Guys whenever I try uploading the file through node.js without the use of any framework through <code>formidable</code> I get an error.The snippet for the said error is</p> <pre><code> res.write('&lt;div id="capslide_img_cont6" class="ic_container"&gt;'); res.write('&lt;div class="overlay" style="display:none;"&gt;&lt;/div&gt;&lt;div class="ic_caption"&gt;"'+comment[i]+'"&lt;/br&gt;&lt;div class ="show_addframe" style="display:none;"&gt;') res.write('&lt;form method="post" action="/add_new_frame_inputs"&gt;&lt;input type="submit" name="add" value="add"/&gt;&lt;/form&gt;'); res.write('&lt;form method="post" action="/change_pic" enctype="multipart/form-data"&gt;&lt;input type = "button" value = "Change Pic" onclick=javascript:document.getElementById("imagefile").click();&gt;&lt;input type="submit" name="submit"/&gt;'); res.write('&lt;input id = "imagefile" type="file" style="visibility: hidden;" name="upload" multiple="multiple"/&gt;&lt;input type="hidden" name="id" value="'+id[i]+'"&gt;&lt;/form&gt;&lt;/br&gt;'); res.write('&lt;form method="post" action="/deletenode"&gt;&lt;input type="hidden" name="name" value="'+namet[i]+'"/&gt;&lt;input type="submit" name="submit" value="delete"&gt;&lt;/form&gt;&lt;/div&gt;&lt;/div&gt;'); res.write('&lt;img src="http://localhost/'+img[i]+'" height="300" width="250"/&gt;&lt;br&gt;'); res.write('&lt;/div&gt;&lt;/div&gt;'); if(i==(namet.length-1)){ res.end('&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;'); </code></pre> <p>This code handles the file upload and it calls this code</p> <pre><code>var form = new formidable.IncomingForm(); form.parse( req, function( error, fields, files ){ fs.rename(files.upload.path, "/var/www/"+files.upload.name); im.resize({ srcPath: "/var/www/" + files.upload.name, dstPath: "/var/www/" + files.upload.name, width: '500', height: '500' }, function(err, stdout, stderr){ if (err) throw err console.log('resized++++') }); console.log("Aftr resized"); img_path=files.upload.name; pic_tags=fields.pic_tags; var objectid=new ObjectID(); pic_id=objectid.toHexString(); docname=fields.name; docparent=fields.parent; doccomments=fields.comments; db.frames.update({pic_id:fields.id},{$set:{pic_id:pic_id}},false,true); db.pictures.insert({imgs:img_path,_id:pic_id,pic_tags:null}); }); console.log("updated frames"); res.writeHead(302,{'location':'/main_menu'}); res.end(); break; </code></pre> <p>The error which I get is this</p> <pre><code> if (err) throw err ^ Error: Command failed: convert: no decode delegate for this image format `/var/www/' @ error/constitute.c/ReadImage/532. convert: missing an image filename `/var/www/' @ error/convert.c/ConvertImageCommand/3011. at ChildProcess.&lt;anonymous&gt; (/home/r121/Desktop/nilesh/node_modules/imagemagick/imagemagick.js:88:15) at ChildProcess.EventEmitter.emit (events.js:91:17) at maybeClose (child_process.js:634:16) at Process._handle.onexit (child_process.js:676:5) </code></pre> <p>Now when I remove the <code>im.resize</code> method the file doesnt gets uploaded at all.Can anyone help me out with this please.Thankx to everyone in Advance.Also the database shows null values for that.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload