upload

PHP Upload File Validation

不打扰是莪最后的温柔 提交于 2019-11-29 04:34:52
I am creating file upload script and I'm looking for the best techniques and practices to validate uploaded files. Allowed extensions are: $allowed_extensions = array('gif','jpg','png','swf','doc','docx','pdf','zip','rar','rtf','psd'); Here's the list of what I'm doing. Checking file extension $path_info = pathinfo($filename); if( !in_array($path_info['extension'], $allowed_extensions) ) { die('File #'.$i.': Incorrent file extension.'); } Checking file mime type $allowed_mimes = array('image/jpeg','image/png','image/gif','text/richtext','multipart/x-zip','application/x-shockwave-flash',

Upload/Download entire directory to Nexus through Maven

雨燕双飞 提交于 2019-11-29 03:57:59
Is it possible to upload/download an entire directory and all of the sub-directories within it to/from a Nexus repository server? In case you want to actually deploy a hierarchy of files, I hacked together a solution using GMaven (groovy embedded in maven). Use the pom below, supply a few properties and hit mvn install . The folder will be crawled and all files inside it will be deployed using an artifactId taken from the relative path. e.g. Given the base folder c:\a\b\c the file c:\a\b\c\def\ghi\jkl.mno would have the artifactId def-ghi-jkl and the packaging mno , this can of course be

How to upload binary file using URLConnection

半腔热情 提交于 2019-11-29 03:56:10
In order to upload a binary file to an URL, I have been advised to use this guide . However, the file is not in a directory, but is stored in a BLOB field in MySql db. The BLOB field is mapped as a byte[] property in JPA: byte[] binaryFile; I have slightly modified the code taken from the guide, in this way: HttpURLConnection connection = (HttpURLConnection ) new URL(url).openConnection(); // set some connection properties OutputStream output = connection.getOutputStream(); PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, CHARSET), true); // set some headers with writer

how to preview an image before upload in various browsers

柔情痞子 提交于 2019-11-29 03:46:24
问题 I want to show preview of an image before it is uploaded. I have found a partial solution that works for ie6 and firefox, and havent yet tested it in ie7 or ie8. But i want a solution that works in safari, ie7 and ie8 as well. Here is the solution obtained by combining the ie6 and firefox solution: function preview(what) { if(jQuery.browser.msie) { document.getElementById("preview-photo").src=what.value; return; } else if(jQuery.browser.safari) { document.getElementById("preview-photo").src

PHP Error - Uploading a file

对着背影说爱祢 提交于 2019-11-29 03:35:08
I'm trying to write some PHP to upload a file to a folder on my webserver. Here's what I have: <?php if ( !empty($_FILES['file']['tmp_name']) ) { move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']); header('Location: http://www.mywebsite.com/dump/'); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <title>Dump Upload</title> </head> <body> <h1>Upload a File</h1> <form action="upload.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /

resume uploads using HTTP?

六月ゝ 毕业季﹏ 提交于 2019-11-29 03:21:21
Is it possible to resume interrupted uploads using HTTP Post? I am working on a project that uploads several files to a HTTP server. Thanks. Assuming you have control at a low enough level on both client and server sides of this project you could achieve this via Content-Range headers in your POST (or PUT) requests that send the data. Yes but it seems you have to use the HTML5 file API to slice the file into chunks: http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-slicing-files well some more info would be useful Most easy is using http://resumablejs.com which uses "HTML5 file API to

Size of uploaded file

断了今生、忘了曾经 提交于 2019-11-29 03:17:25
问题 Do web browsers send the file size in the http header when uploading a file to the server? And if that is the case, then, is it possible to refuse the file just by reading the header and not wait for the whole upload process to finish? 回答1: http://www.faqs.org/rfcs/rfc1867.html HTTP clients are encouraged to supply content-length for overall file input so that a busy server could detect if the proposed file data is too large to be processed reasonably But the content-length is not required,

upload file using jquery and handler(ashx)

徘徊边缘 提交于 2019-11-29 03:13:49
问题 I am trying to upload a file using jquery ajax with handler (c#). The problem is, when I call the handler I get context.Request.File.Count=0 Here is the aspx code: <!--aspx file code--> <script language="javascript" type="text/javascript"> $().ready(function () { $('#save').click(function (e) { CalluploaderHandler(); }); }); function CalluploaderHandler() { $.ajax({ type: "POST", url: "Services/UPloader.ashx", contentType: "application/json; charset=utf-8", success: OnComplete, error: OnFail

jQuery equivalent to XMLHttpRequest's upload?

…衆ロ難τιáo~ 提交于 2019-11-29 03:00:19
问题 Working with HTML5's File API, the upload is made via an object called upload in the XMLHttpRequest . This is the tutorial I'm working with (and the Google cache mirror since it's down at the moment). This is the relevant part: // Uploading - for Firefox, Google Chrome and Safari xhr = new XMLHttpRequest(); // Update progress bar xhr.upload.addEventListener("progress", function (evt) { As you can see, to track the upload progress, the XMLHttpRequest object has a property named upload , which

Upload file with Fetch API in Javascript and show progress [duplicate]

雨燕双飞 提交于 2019-11-29 02:56:33
问题 This question already has an answer here: Upload progress indicators for fetch? 8 answers I'm using Fetch API in Javascript to upload big file to server. Is there any event in Fetch API that I could use to track progress of upload? 回答1: This is NOT possible. The reason is the way the Fetch API works. The fetch method returns a Promise; the Promise API uses a then method to which you can attach “success” and “failure” callbacks. Therefore, you can gain access to progress. Still, don't lose