Uploading files in ASP.NET MVC without creating a view, utilizing Valums Ajax Uploader technology

I recently completed a tutorial on ASP.NET MVC file uploads using Valums plugin and made sure to place all the necessary js, css, and gif files in their respective folders. However, I am facing an issue where the view is not displaying anything.

<link href="@Url.Content("~/css/fileuploader.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/js/fileuploader.js")" type="text/javascript"></script>
<div id="file-uploader">
    <noscript>
        <p>
            Please enable JavaScript to use file uploader.</p>
    </noscript>
</div>
<script type="text/javascript">
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader'),
action: '@Url.Action("upload")' // specify path for handling upload
//,allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'] // uncomment if only images are allowed
sizeLimit: 4000000, // maximum size limit of 4MB
minSizeLimit: 0 // minimum size required

 });
</script>

I am encountering an error with this script. When inspecting with Firebug, the error message indicates:

missing } after property list

Upon reviewing the page source:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Home Page</title>
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script>
</head>
<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>My MVC Application</h1>
            </div>
            <div id="logindisplay">
                    [ <a href="/Account/LogOn">Log On</a> ]

            </div>
            <nav>
                <ul id="menu">
                    <li><a href="/">Home</a></li>
                    <li><a href="/Home/About">About</a></li>
                </ul>
            </nav>
        </header>
        <section id="main">
            <link href="/css/fileuploader.css" rel="stylesheet" type="text/css" />
<script src="/js/fileuploader.js" type="text/javascript"></script>
<div id="file-uploader">
    <noscript>
        <p>
            Please enable JavaScript to use file uploader.</p>
    </noscript>
</div>
<script type="text/javascript">
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader'),
action: '/Home/upload' // provide path for uploading functionality
//,allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'] // specify if limited to image uploads only
sizeLimit: 4000000, // max file size set to approximately 4MB

minSizeLimit: 0 // lowest acceptable file size

 });
</script>

        </section>
        <footer>
        </footer>
    </div>
</body>
</html>

Answer №1

There seems to be a trailing comma that needs to be removed:

minSizeLimit: 0, // min size

Additionally, a comma is missing here:

action: '@Url.Action("upload")' // provide the path to your page for handling uploads

Please ensure that your javascript code is valid:

<script type="text/javascript">
    var uploader = new qq.FileUploader({
        element: document.getElementById('file-uploader'),
        action: '@Url.Action("upload")',
        sizeLimit: 4000000,
        minSizeLimit: 0
    });
</script>

I see now that the errors were in the original article you referenced. You may want to inform the author about these mistakes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a Dual Y-Axis Chart with Two Sets of Data in chart.js

I utilized the chart.js library to write the following code snippet that generated the output shown below. My primary concern is how to effectively manage the labels on the horizontal axis in this scenario. CODE <!DOCTYPE html> <html lang="en"& ...

Review the file's content prior to uploading

Before uploading a zip or rar file to the server, I need to ensure that the content is safe and not malicious. Let me paint the picture for you. In my web project, there are two types of users: 1: Regular registered users 2: Project administrators Any ...

trouble with fetching data

Within my Backbone view, I have the following code snippet: var BookView = Backbone.View.extend({ initialize: function() { this.render(); }, render: function() { this.model.fetch({ success : function(model, resp, opt) { alert(this.$el. ...

Utilizing attributes as scope properties within AngularJS

I am currently working on a directive and I need to pass the Attributes (Attrs) to the $scope, however, I am facing some difficulties in achieving this. Specifically, my goal is to assign attributes in my template based on the name set in my date-picker ta ...

Tips for improving the performance of MongoDB queries in a Node.js environment

I am currently facing an issue with my code running in nodejs where I need to call a MongoDB query with aggregation properties using callbacks. However, the code is not functioning as expected. I want the code to run asynchronously so that once the MongoDB ...

Encountering an issue with Jest when using jest.spyOn() and mockReturnValueOnce causing an error

jest --passWithNoTests --silent --noStackTrace --runInBand --watch -c jest-unit-config.js Project repository An error occurred at jest.spyOn(bcrypt, 'hash').mockRejectedValue(new Error('Async error message')) Error TS2345: The argum ...

Sending JavaScript objects from React.js to Node.js

I send the object to the backend (Node js) when making an API call, but I am logging the objects for verification. Initially, I used POSTMAN to check and it worked perfectly. However, when attempting to pass an object in the frontend (Reactjs), it appear ...

Tips for iterating through data in JSON format and displaying it in a Codeigniter 4 view using foreach

As a newcomer to JSON, I have a question - how can I iterate through JSON data (which includes object data and object array data) using jQuery/javascript that is retrieved from an AJAX response? To illustrate, here is an example of the JSON data: { "p ...

The Javascript regex allows for the presence of positive and negative numbers, with the option of a single minus symbol

oninput="this.value = this.value.replace(/[^-0-9.]/g, '') This code snippet is utilized in my current project. However, there seems to be an issue where the input can contain more than one minus sign, as shown here: ---23 To address this p ...

When attempting to submit data, the Magnific Popup page is restored to its default format

I am facing an issue with my Magnific Popup page: function dataLink(){ $.magnificPopup.open({ items: { src: 'datapage.html', type: 'ajax' }, closeOnContentClick : false, clos ...

Model for handling Node/Express requests

I always saw Node.js/Express.js route handlers as akin to client-side EventListeners such as onClick, onHover, and so on. For example: document .getElementById('btn') .addEventListener('click', function() { setTimeout(functi ...

Spinning an object using JQuery

I am currently working on a project to test my skills. I have set up a menu and now I want to customize it by rotating the icon consisting of three vertical lines by 90 degrees every time a user clicks on it. This icon is only visible on smartphones when t ...

Guide to making Bootstrap collapsible panels with full-width content that do not affect neighboring columns

I'm currently working on a responsive grid that displays items with expandable details when clicked. My issue is that when one item expands, the elements next to it collapse down, which is not what I want. I want all items to stay at the top and have ...

Creating a header upon clicking a link

Is it feasible to establish a request header when a user clicks on a link? ...

Creating a mesmerizing glass effect in Three.js using a PNG image mask on a video texture

The other day, I revisited activetheory.net and was captivated by the beautiful glass effect on the Homescreen logo border. I tried to replicate it by examining the minified code and discovered they were using a PNG as a mask. I successfully loaded a PNG ...

Creating a Slider with a Multitude of Images

I am working on a project to develop a gallery that pulls images from a JSON source. I have successfully implemented infinite scrolling to display the images on the first page. However, I am now facing a challenge when it comes to showing the selected imag ...

Tips for incorporating material-ui icons into the column component of a data-grid component

I am currently working with the material-ui data-grid and I would like to display Edit icons from material-ui next to each row. Unfortunately, the data-grid does not provide any props specifically for this purpose. Below is the code snippet: import React ...

Storing user authentication tokens securely in session storage within Next.js can help maintain a

Is there a way to ensure that user data remains persistent even after a page refresh? I considered storing it in local storage, but that may result in a flash of unauthenticated content. Storing it in a cookie could also be problematic when working with ...

Ways to hide the value from being shown

I have integrated jscolor (from jscolor) to allow users to pick a color with an input field. However, I am facing issues in styling it as I'm unable to remove the hex value of the selected color and couldn't find any relevant documentation on av ...

What causes the malfunction of the save function in express?

Today marks my first venture into using Express. I attempted to create a straightforward route, but unfortunately, my save function is not cooperating. Despite scouring similar inquiries on stackoverflow, I have been unable to find a solution. Any assistan ...