Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: "HTTP Error. Upload URL might be wrong or doesn't exist." my runtime is silverlight #1084

Closed
techno489 opened this issue Jun 9, 2014 · 15 comments

Comments

@techno489
Copy link


I have been trying to get this to upload large files 1GB in size
I have read many many posts and tried numbers of options but simply can't get large files to upload, I can upload 300MB files but any more then that I get "HTTP Error. Upload URL might be wrong or doesn't exist."

my jquery_ui_widget.html code is

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<title>Plupload - jQuery UI Widget</title>

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="../../js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>

<!-- production -->
<script type="text/javascript" src="../../js/plupload.full.min.js"></script>
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>

<!-- debug
<script type="text/javascript" src="../../js/moxie.js"></script>
<script type="text/javascript" src="../../js/plupload.dev.js"></script>
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
-->

</head>
<body style="font: 13px Verdana; background: #eee; color: #333">

<h1>jQuery UI Widget</h1>

<p>You can see this example with different themes on the <a href="http://plupload.com/example_jquery_ui.php">www.plupload.com</a> website.</p>

<form id="form" method="post" action="../dump.php">
<div id="uploader">
<p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
</div>
<br />
<input type="submit" value="Submit" />
</form>

<script type="text/javascript">
// Initialize the widget when the DOM is ready
$(function() {
$("#uploader").plupload({
// General settings
// runtimes : 'html5,flash,silverlight,html4',
runtimes : 'silverlight',
url : '../upload.php',

// User can upload no more then 20 files in one go (sets multiple_queues to false)
max_file_count: 20,

chunk_size: '1mb',

// Resize images on clientside if we can
resize : {
width : 200,
height : 200,
quality : 90,
crop: true // crop to exact dimensions
},

filters : {
// Maximum file size
max_file_size : '1000mb',
// Specify what files to browse for
mime_types: [
{title : "Video files", extensions : "mpg,mpeg,divx,avi,mp4,swf,wmv,xvid,yuv,vob"},
{title : "Audio files", extensions : "aac,wav,mp3"},
{title : "Image files", extensions : "jpg,gif,png,bmp"},
{title : "Zip files", extensions : "7-Zip,zip,rar"}
]
},

// Rename files by clicking on their titles
rename: true,

// Sort files
sortable: true,

// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,

// Views to activate
views: {
list: true,
thumbs: true, // Show thumbs
active: 'thumbs'
},

// Flash settings
flash_swf_url : '../../js/Moxie.swf',

// Silverlight settings
silverlight_xap_url : '../../js/Moxie.xap'
});


// Handle the case when form was submitted before uploading has finished
$('#form').submit(function(e) {
// Files in queue upload them first
if ($('#uploader').plupload('getFiles').length > 0) {

// When all files are uploaded submit form
$('#uploader').on('complete', function() {
$('#form')[0].submit();
});

$('#uploader').plupload('start');
} else {
alert("You must have at least one file in the queue.");
}
return false; // Keep the form from submitting
});
});
</script>
</body>
</html>


</code>


my upload.php code is this
<code>
<?php
/**
* upload.php
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/

#!! IMPORTANT:
#!! this file is just an example, it doesn't incorporate any security checks and
#!! is not recommended to be used in production environment as it is. Be sure to
#!! revise it and customize to your needs.


// Make sure file is not cached (as it happens for example on iOS devices)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

/*
// Support CORS
header("Access-Control-Allow-Origin: *");
// other CORS headers if any...
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
exit; // finish preflight CORS requests here
}
*/

// 5 minutes execution time
// @set_time_limit(5 * 60);

// Uncomment this one to fake upload time
// usleep(5000);

// Settings
$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$targetDir = 'uploads';
// $cleanupTargetDir = fauls; // Remove old files
// $maxFileAge = 5 * 3600; // Temp file age in seconds


// Create target dir
if (!file_exists($targetDir)) {
@mkdir($targetDir);
}

// Get a file name
if (isset($_REQUEST["name"])) {
$fileName = $_REQUEST["name"];
} elseif (!empty($_FILES)) {
$fileName = $_FILES["file"]["name"];
} else {
$fileName = uniqid("file_");
}

$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;

// Chunking might be enabled
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;


// Remove old temp files
if ($cleanupTargetDir) {
if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
}

while (($file = readdir($dir)) !== false) {
$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;

// If temp file is current file proceed to the next
if ($tmpfilePath == "{$filePath}.part") {
continue;
}

// Remove temp file if it is older than the max age and is not the current file
if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {
@Unlink($tmpfilePath);
}
}
closedir($dir);
}


// Open temp file
if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}

if (!empty($_FILES)) {
if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
}

// Read binary input stream and append it to temp file
if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
} else {
if (!$in = @fopen("php://input", "rb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
}

while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}

@fclose($out);
@fclose($in);

// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
// Strip the temp .part suffix off
rename("{$filePath}.part", $filePath);
}

// Return Success JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
</code>

I think I need something to keep the connection to the domain active but not sure.
I only know very little about coding and mostly try what I read others have done.

the closest topic I found was https://github.com//issues/855
but that didn't help me or I didn't fully understand how he fixed his problem

I edited the php.ini on my domain "max_execution_time = 0" as I read somewhere to do this to stop drop out with lard files but it still didn't fix my problem.

Any help with this would be great, I have been busy with this now for about 5 days spending most my time trying to make this work.

Cheers

@jayarjo
Copy link
Contributor

jayarjo commented Jun 9, 2014

Check this thread: http://plupload.com/punbb/viewtopic.php?id=4069

@techno489
Copy link
Author

Thanks for that link.
I found it a bit daunting as I don't fully understand it, But it did hint to me about changing "max_file_size" to "post_file_size" in the .html so I googled max_file_size and found another post about someone having the same kind of problem and making the same edit as above plus making the change in host post.ini to

post_max_size = 1000M
upload_max_filesize = 1000M
memory_limit = 1128M

Default settings on the host was 10MB

After doing both edits I was able to upload a file 530MB.
I will do more testing today with larger files and report back.

@techno489
Copy link
Author

well it's a hit and miss but I have uploaded 3 900mb files not a problem but for some reason small files about 100mb or less sometimes upload and other time only part uploads 1mb and then errors.

@jayarjo
Copy link
Contributor

jayarjo commented Jun 10, 2014

Did you actually get the file on the server? The error says that upload.php cannot be found at the specified url. Make sure that you reference it properly (try absolute url instead of relative one).

@techno489
Copy link
Author

yes I did get the file on there, I might have removed the file now, as I am only testing until I get it right

@jayarjo
Copy link
Contributor

jayarjo commented Jun 10, 2014

Have you tried absolute url? Please try (do not just assume that it will be the same).

@techno489
Copy link
Author

I made it absolute in the widget but can't in the php $targetDir = 'uploads'; when I change it to absolute no files show in the uploads folder. since it still works this way I will leave it. I don't know why one way would be better then the other when the end result is the same. except I haven't had any error yet after about 16 uploads

@jayarjo
Copy link
Contributor

jayarjo commented Jun 10, 2014

You shouldn't change $targetDir to url. $targetDir should be a path to directory to store the uploads.

So it works now?

@techno489
Copy link
Author

I have been testing it all day here and there and not one error yet.
I think its all good now. I will get some others to upload and try it out.

@jayarjo jayarjo closed this as completed Nov 26, 2016
@kushlces
Copy link

I am currently having this issue. For me, I don't think its related to the server configuration but rather a netwrok issue. If I change my ISP, it works. Basically, file gets uploaded with some internet providers and not with others. I will update if I figure out the exact cause.

@kjin9174
Copy link

Hello jayarjo
are you round?

@kjin9174
Copy link

I wanna know how url of upload.js works?

@kjin9174
Copy link

how to connect upload.js with upload.php???

@jayarjo
Copy link
Contributor

jayarjo commented Nov 13, 2017

@kjin9174 we have a getting started guide here: http://www.plupload.com/docs/v2/Getting-Started

@haiderpro
Copy link

This is an old thread but this problem occurred to our server today and after investing a good amount of time, I found that the problem was due to Apache's mod_evasive module. If the following error is haunting you:
"Upload URL might be wrong or doesn't exist"

Then ask your web host to check if Apache's mod_evasive module is installed on the server and ask them to disable or remove it and the problem will be fixed.

Apache's mod_evasive module is to avoid brute force attack but it false positively detect file uploads as attack and blocks the file uploads. There may be other reasons also but if some files are uploading and some are not then this is what is going to solve the issue.

Sharing this information to make things easier for others :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants