Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploadify Loading Slow and Uncaught Errors

So I'm trying to implement upload functionality on my site using the uploadify plugin found here So far here's my html:

<form id="uploadForm" action="upload_file.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file_upload" id="file_upload">
    <a href="javascript:$('#file_upload').uploadify('stop')">Stop Uploading</a> | <a href="javascript:$('#file_upload').uploadify('upload','*')">Upload</a>
</form>

And here's my jquery:

$('#file_upload').uploadify({
    'auto' : false,
    'buttonText' : "BROWSE",
    'fileSizeLimit' : '100MB',
    'queueSizeLimit' : 1,
    'fileTypeDesc' : 'Doc Files',
    'fileTypeExts' : '*.doc; *.docx',
    'buttonImage' : 'Images/browse-btn.png',
    'preventCaching' : false,
    'swf'      : 'uploadify.swf',
    'uploader' : 'upload_file.php'
});

And i have this at the top of my document:

<script type="text/javascript" src="JS/jquery.uploadify.min.js"></script>
<link rel="stylesheet" type="text/css" href="CSS/uploadify.css" /> 

So the browse button shows up, the options all work find, but the problem is two things:
1) The upload bar won't load unless I refresh the page. The upload bar is this: Upload Status

Is this some swf problem? I picked up a few things here and there from people saying that there are problems with loading swf on browsers.

2) When I try to hit the x on the status bar or try to click the cancel/upload links below it, the browser gives me this error:

Uncaught Call to StartUpload failed jquery.uploadify.min.js:16
Uncaught Call to CancelUpload failed 

The files end up not uploading (obviously). Any idea how to fix the problem?

like image 764
John Bernal Avatar asked Nov 27 '22 16:11

John Bernal


1 Answers

Which version of jQuery you're using and at what browser you're getting an error. Please add below jquery version at the top of all the included js files

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script

I've pasted your all code and trying with uploadify 3.1 version and I'm not getting any error. Below is my code for your confirmation.

    <link rel="stylesheet" type="text/css" href="css/uploadify.css">
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.uploadify-3.1.min.js"></script>
    <script type="text/javascript">
    $(function() {
            $('#file_upload').uploadify({
            'auto' : false,
            'buttonText' : "BROWSE",
            'fileSizeLimit' : '100MB',
            'queueSizeLimit' : 1,
            'fileTypeDesc' : 'Doc Files',
            'fileTypeExts' : '*.doc; *.docx',           
            'preventCaching' : false,
            'swf'      : 'uploadify.swf',
            'uploader' : 'uploadify.php'
        });

    });
    </script>
</head>
<body>
<form id="uploadForm" action="upload_file.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file_upload" id="file_upload">
    <a href="javascript:$('#file_upload').uploadify('stop')">Stop Uploading</a> | <a href="javascript:$('#file_upload').uploadify('upload','*')">Upload</a>
</form>

This is my complete code on which I'm not getting an error. Please try with replacing your code with above code.

I hope it'll help you.

like image 115
Dhaval Avatar answered Dec 05 '22 00:12

Dhaval