Issue with uploading files using Laravel and Vue on the live server

Recently, I encountered an issue with a component in my project hosted on Namechap. The component involves uploading a video file and it was working perfectly fine on both my local machine and the production server. However, after making some changes to the project, I noticed that the upload functionality stopped working on the production server.

The project uses Vue v. 1.0.28, and the upload component contains a method called fileInputChange() which sends form data to the /upload endpoint. Strangely, on the production server, the backend is unable to read the form data being sent.

<template>
  <div class="card-content col-md-10 col-md-offset-1">

      <div v-if="!uploading">
          <div class="col-md-12 Image-input__input-wrapper">
              Upload video
              <input type="file" name="video" id="video" @change="fileInputChange" class="Image-input__input" accept="video/*">
          </div>
      </div>

      ...

</script>

The problem arises when the request object in my controller's store function turns out to be empty on the production server causing issues related to finding the Video model. Despite inspecting the network tab and confirming that the payload is being sent correctly, the controller fails to find the necessary data.

No query results for model [App\Video].

This is the relevant section of the controller:

class VideoUploadController extends Controller
{
    public function index()
    {
      return view('video.upload');
    }

    ...
}

After discussing the issue with Namecheap support and creating a ticket, the problem resolved on its own without any apparent changes being made by either party. While this unexpected fix is reassuring, I remain concerned about preventing similar issues in the future.

Answer №1

When using Laravel's $request->all() method, it only retrieves data from the input fields. This means that in the store() method of the VideoUploadController, calling $request->all() will result in an empty object.

In your code, you are invoking the this.store() function after checking if the isVideo flag is true when a file change occurs. However, because of this sequence, the parameters uid and video are not passed to the function.

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

Is it feasible to conceal certain parameters within a URL using Angular UI Router?

Looking to pass two values to a new ui-view via parameters: item id list of objects However, I want the new view to display only the id in the browser URL and not the stringified array of objects: http://www.myapp.com/#/my-view/4 INSTEAD OF http://ww ...

Is Consistency Possible with CSS Transition Direction?

Take a look at this example: https://codepen.io/jon424/pen/XWzGNLe In the provided code snippet, there is a button that can toggle the visibility of an image. When clicked, the image disappears from bottom to top and reappears when clicked again. The use ...

Eliminate any line breaks from the information retrieved from the node event process.stdin.on("data") function

I've been struggling to find a solution to this issue. No matter what approach I take, I can't seem to remove the new line character at the end of my string. Take a look at my code below. I attempted using str.replace() in an effort to eliminate ...

Troubleshooting problem with strokeRect on canvas following a CSS transform rotate(90deg)

English is not my strong suit, so please bear with me. Let me outline the issue I'm currently grappling with. I'm in the process of developing a function that allows users to draw a rectangle on a canvas using their mouse (specifically, using t ...

Calling a Coldfusion function from JavaScript/jQuery using a remote server connection

Although I am well-versed in JavaScript/jQuery, I am a newcomer to ColdFusion. After extensive research, I still can't figure out what seems like it should be a simple problem. My goal is to trigger a server-side call to a ColdFusion function from wi ...

Uploading files using Ajax in the Laravel framework

I am attempting to utilize ajax to upload a file in Laravel. $("#stepbutton2").click(function(){ var uploadFile = document.getElementById("largeImage"); if( ""==uploadFile.value){ } else{ v ...

Generating div elements of varying colors using a combination of Jinja templating and JavaScript loop

Utilizing jinja and javascript in my template, I am creating multiple rows of 100 boxes where the color of each box depends on the data associated with that row. For instance, if a row in my dataset looks like this: year men women 1988 60 40 The co ...

PHP - Unexpected outcome observed while accessing the id attribute

I'm encountering difficulty accessing a specific attribute in my Laravel application. Here is a basic query to retrieve a user: $login = Users::select('user_id' ,'email', 'password')->where('email', Input:: ...

Is this code in line with commonly accepted norms and standards in Javascript and HTML?

Check out this Javascript Quiz script I created: /* Jane Doe. 2022. */ var Questions = [ { Question: "What is 5+2?", Values: ["7", "9", "10", "6"], Answer: 1 }, { Question: "What is the square root of 16?", Values: ["7", "5", "4", "1"], Answer: ...

The issue arises when trying to apply CSS and minified JavaScript after adding new data in jQuery Mobile

I am having an issue with adding data and displaying it on a list. The problem arises when I add data through AJAX. In the success function, after showing the alert "successfully added", I used location.reload(), which takes me to the homepage (div tag dat ...

What do you understand by the term "cyclic data structures"?

According to the information found on the JSON site, it states: JSON does not allow for cyclic data structures, hence one must avoid passing cyclical structures to the JSON stringify function. I am curious about what this means. Could someone provide a ...

Retrieve and showcase Json data from two different nodes using Ajax

I'm struggling to show the data from json properly. The title displays correctly, but item.volumeInfo.industryIdentifiers.type is coming back as undefined. $.ajax({ url: 'https://www.googleapis.com/books/v1/volumes?q=:isbn=0-13-727827-6', d ...

Firefox fails to render SVG animation

Currently, I'm attempting to incorporate this unique animation into my website: http://codepen.io/dbj/full/epXEyd I've implemented the following JavaScript code in order to achieve the desired effect: var tl = new TimelineLite; tl.staggerFromTo ...

Can the loading gif be displayed when a website is loading or when content is being posted

I've implemented two functions in my site master to display and hide a loading GIF. However, I don't want to call it for every AJAX call or before every post method. Is there a way without using jQuery for me to check if the site is loading and ...

Vue.js - Using Filters to Filter Data from Multiple Fields

I'm currently working on filtering a nested array inside an array of objects in Vue.js. Below is a code snippet from the component: filteredProducts: function() { if (!this.filters.appointments.length && !this.filters.powers.length && !this.filters. ...

Obtain the HTML source code for a webpage that has been scrolled down using Python web scraping with Selenium

Even after executing a script to scroll down, I am only able to retrieve the initial html code containing 11 hotels. How can I access the entire data source code by scrolling down to scrape all the available hotels? If the driver.execute_script is suppose ...

The dimensions of the sprites within Three.js geometry

I am interested in creating an animation of sprites moving along a figure, particularly sprites that walk along the figure. An example of what I envision can be seen here: http://armsglobe.chromeexperiments.com/ I found some helpful information related t ...

Displaying Highcharts Graph in Dual Containers

Could you kindly review this demonstration and provide guidance on how I can display one Highcharts chart in two separate containers? I have attempted both: renderTo: 'container', renderTo: 'container2', and renderTo: 'containe ...

I'm having trouble getting the HTML checkbox symbol to show up correctly. My goal is to create all the elements using the DOM

I am currently building all of my elements manually through the DOM tree, and I am attempting to insert a checkbox symbol in this manner: //Add date var tdDate = document.createElement("td"); tdDate.textContent = ("" + workoutList[idx].date); ...

Can a text file be loaded into the title of a Bootstrap tooltip?

Looking to dynamically load a text file into bootstrap tooltip titles. Here is a snippet of working code with hardcoded values: <div> <a id="A" type="button" class="btn btn-outline-secondary btn-lg" data-toggle=& ...