Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd new file extension with Javascript without removing old one
    primarykey
    data
    text
    <p><br/> There has been few similar questions (<a href="https://stackoverflow.com/questions/190852/how-can-i-get-file-extensions-with-javascript">here</a> and <a href="https://stackoverflow.com/questions/5953239/how-do-i-change-file-extension-with-javascript">here</a>) but not exactly what I want and I haven't been able to combine the codes.</p> <p>I have an upload form and if user uploads ZIP or RAR file, I want to add .jpg file extension without removing .zip or .rar extension. For example, "file.zip" to "file.zip.jpg". </p> <p>I need this because users can upload images and PDF files into my server but if somebody has multiple files, it's better to zip them. I also write certain metadata for the uploaded files based on the selections user has made in the upload form. Metadata is for the <a href="http://www.elvisdam.com/" rel="nofollow noreferrer">Elvis</a> so I can move the pictures around my server based on the metadata. Problem is that certain metadata can't be written in ZIP files in Elvis at the moment so my workaround is to change the file extension as .jpg to fool Elvis and write metadata for the file. Yes, this is a bad workaround but at the moment it serves my purposes.</p> <p>I don't have much code ready because I don't know where should I begin. Also, you won't drop from the chair when you see my JS functions ;) JS code can be written with jQuery.</p> <pre><code>&lt;form action="http://url.here" method="post" enctype="multipart/form-data" id="form" onsubmit="addExtension();"&gt; &lt;label for="file"&gt;File &lt;/label&gt; &lt;input type="file" name="Filedata" id="file"&gt; &lt;input type="submit" value="Upload" /&gt; &lt;/form&gt; </code></pre>
    singulars
    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.
 

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