Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:14:00+00:00 2026-06-02T01:14:00+00:00

I have a JavaScript function below where it displays a message after file uploading

  • 0

I have a JavaScript function below where it displays a message after file uploading is complete:

function stopVideoUpload(success) {
  var namevideofile = $('.fileVideo').val();
  var result = '';
  if (success == 1) {
    result = '<span class="msg">The file was uploaded successfully!</span><br/><br/>';
    $('.listVideo').append(namevideofile + '<br/>');
  }
  else {
    result = '<span class="emsg">There was an error during file upload!</span><br/><br/>';
  }
  return true;
}​

Below is the php script which is on another page which successfully uploads the files:

if( file_exists("VideoFiles/".$_FILES['fileVideo']['name'])) {
    $parts = explode(".",$_FILES['fileVideo']['name']);
    $ext = array_pop($parts);
    $base = implode(".",$parts);
    $n = 2;

    while( file_exists("ImageFiles/".$base."_".$n.".".$ext)) $n++;
    $_FILES['fileVideo']['name'] = $base."_".$n.".".$ext;

    move_uploaded_file($_FILES["fileVideo"]["tmp_name"],
    "VideoFiles/" . $_FILES["fileVideo"]["name"]);
    $result = 1;

}
    else
      {
      move_uploaded_file($_FILES["fileVideo"]["tmp_name"],
      "VideoFiles/" . $_FILES["fileVideo"]["name"]);
      $result = 1;

      }


?>

<script language="javascript" type="text/javascript">window.top.window.stopImageUpload(<?php echo $result;?>);</script>  

Now except having var namevideofile to retrieve the value from the file input value (.fileVideo is the class for the file input), what I want it to do is that when the uploading is complete, the name given to file in the server would be var namevideofile. So if I have 2 files known as video.png, as I stated in my php code that if file exists then add a number to end of file name so that would create video.png and video1.png in server.

So when I append namevideofile, it should display video.png and video1.png after uploading is completed for both files. The problem with var namevideofile = $('.fileVideo').val();, is that it displays both file names as video.png which is incorrect.

So does anyone know how to change var namevideofile so that it retrieves the file name from the server after uploading? The issue is that the php script is on a separate page (videoupload.php) to the JS function (QandATable.php) so does ajax need to be involved here or not.

Anyone who could provide an example of how this can be coded would be very helpful to me 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:14:01+00:00Added an answer on June 2, 2026 at 1:14 am

    you can echo and store the value in a javaScript variable:

    var namevideofile = <php echo $filename; ?>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JavaScript of ajax uploader as below; $(document).ready(function(){ var qwerty = $('#qwerty').val(); $('#demo1').ajaxupload({
I have Javascript as below: <script type="text/javascript" language="javascript"> function redirectToPrevious(abcURL) { window.location.replace(abcURL); } function
in .gsp file i have javaScript function <script type=text/javascript> function getCurrentItemNumber(){ return document.getElementById('item_itemNumber').innerHTML.substr(6); }
I have this javascript, jquery function, (below) It gets the text inside each table
I have a javascript function that manipulates the DOM when it is called (adds
We have a JavaScript function named move which does just windows.location.href = any given
I have a JavaScript function, pop_item . I have to call this from PHP,
I have a javascript function (class) that takes a function reference as one paremter.
I have a javascript function (function1) that checks some global variables (can the user
I have a javascript function that calls a generic function to make an ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.