upload

How do I tell if someone's faking a filetype? (PHP)

南楼画角 提交于 2020-01-12 04:50:08
问题 I'm programming something that allows users to store documents and pictures on a webserver, to be stored and retrieved later. When users upload files to my server, PHP tells me what filetype it is based on the extension. However, I'm afraid that users could rename a zip file as somezipfile.png and store it, thus keeping a zip file on my server. Is there any reasonable way to open an uploaded file and "check" to see if it truly is of the said filetype? 回答1: Magic number. If you can read first

Wordpress: Upload Image in Admin Options Page

青春壹個敷衍的年華 提交于 2020-01-11 17:25:30
问题 I am developing my first wordpress plugin. It only needs to allow a user to change a logo in a custom template and change a color scheme in the custom template. I have made an admin options page and now want to add a field to allow a user to upload an image. How can I upload an image to the wp-content/uploads folder. So far, I have this within a table: <td><input name="logo_image" type="file" id="logo_image" value="" /></td> Is this the right approach? If so, how do I direct the file to the

How can i close filpond browse area after upload

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-11 13:10:05
问题 I've init filepond with jquery and i need to close browse panel showing after uploading file to close when file uploaded. So far i set filepond server this way: server: { process: { url: window.urls.process_files, method: 'POST', headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), mimes: accepted_file_types }, onload: (response) => { const res = JSON.parse(response); }, } I need to close uploaded area with preview to blank uploading panel when file uploaded (in the onLoad

How can i close filpond browse area after upload

与世无争的帅哥 提交于 2020-01-11 13:08:07
问题 I've init filepond with jquery and i need to close browse panel showing after uploading file to close when file uploaded. So far i set filepond server this way: server: { process: { url: window.urls.process_files, method: 'POST', headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), mimes: accepted_file_types }, onload: (response) => { const res = JSON.parse(response); }, } I need to close uploaded area with preview to blank uploading panel when file uploaded (in the onLoad

Upload data method in REST web service

不打扰是莪最后的温柔 提交于 2020-01-11 10:04:56
问题 Do anyone know how can I write POST method in RESTful web service to upload data using java ? I found that smartupload and commons.upload are just for web page. 回答1: You can use some JAX-RS library, like Apache Wink, so you can write something like this: @Path("/upload") class UploadResource { @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response upload(byte[] input) { // store input somewhere return Response.ok().build(); } } So you will receieve your file is byte[] . You can

Firefox XHR not firing upload progress events

别等时光非礼了梦想. 提交于 2020-01-11 07:44:12
问题 Pretty straight-forward HTML/JS that: Takes a Base64-encoded PNG Converts it to a blob Sets an img.src to verify that it's a valid PNG Uploads it via XHR after setting event handlers In Firefox 12 I get the " loadstart " and " loadend " events but no " progress " events. In Chrome 20 everything works fine. This file is named "image.html" so it just uploads to itself for testing. I also tried setting a content-legnth header but that didn't change the results in Firefox so I commented it out.

PHP Upload - Allow only jpg files

心已入冬 提交于 2020-01-11 07:23:47
问题 This is what I currently have: $file_name = $HTTP_POST_FILES['uid']['name']; $user= 'FILENAME'; $ext = pathinfo($file_name, PATHINFO_EXTENSION); $new_file_name=$user . '.' . $ext; $path= "uploads/images/users/".$new_file_name; if($ufile !=none) { if(copy($HTTP_POST_FILES['uid']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['uid']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['uid']['type']."<BR/>"; } else {

Heroku django project read-only file system

梦想与她 提交于 2020-01-11 05:07:06
问题 I'm deploying django project on heroku, it works fine, but in django admin, when i'm trying to upload image i got error: OSError at /admin/blocks/block/add/ [Errno 30] Read-only file system: '/home/goldwedd' 回答1: This is by design. Your app is compiled into a slug for fast distribution by the dyno manager. The filesystem for the slug is read-only, which means you cannot dynamically write to the filesystem for semi-permanent storage. The following types of behaviors are not supported: Caching

Compress files (client side) and upload

心不动则不痛 提交于 2020-01-11 03:23:05
问题 What HTML5/Javascript method I can use to upload and compress files on the client side? The code to select multiple files: Note: If you upload files occupying this method, the server is slow to compress files, to prevent overloading is preferable to compress from the client side <form method="post" enctype="multipart/form-data"> <input type="file" name="fileselect[]" multiple="multiple"> <input type="submit"> </form> The code as I'd like it to be: <script> ... </script> ... <form method="post

Save files in database with entity framework

强颜欢笑 提交于 2020-01-10 09:56:08
问题 I have an ASP.NET MVC solution built on Entity Framework with Microsoft SQL Server 2008. I need to create a function that lets my users upload files. What I would like is: A solution that uses the Entity Framework to store files in the Database A solution that detects and prevents from uploading the same file twice via some kind of hash/checksum Tips on database/table design 回答1: The "right" way to store a file in a SQL Server 2008 database is to use the FILESTREAM data type. I'm not aware