upload

PHP Rename File name if Exists Append Number to End

倖福魔咒の 提交于 2019-11-28 17:18:18
I'm trying to rename the file name of an image when it's uploaded if it exists, say if my file name is test.jpg and it already exists I want to rename it as test1.jpg and then test2.jpg and so on. With the code I've written its changing my file name like so test1.jpg and then test12.jpg any advice on fixing this would be great thank! PHP $name = $_FILES['picture']['name']; $actual_name = pathinfo($name,PATHINFO_FILENAME); $extension = pathinfo($name, PATHINFO_EXTENSION); $i = 1; while(file_exists('tmp/'.$actual_name.".".$extension)) { $actual_name = (string)$actual_name.$i; $name = $actual

HTML5 resumable and chunked upload of large files (> 500MB)

梦想与她 提交于 2019-11-28 17:17:33
Is it possible to implement resumable and slice (chunked) upload for large sizefiles (>500MB) using HTML5 (BLOB API)? I tried to use https://github.com/blueimp/jQuery-File-Upload . In documentation its said that is supports: Resumable uploads: Aborted uploads can be resumed with browsers supporting the Blob API. Chunked uploads: Large files can be uploaded in smaller chunks with browsers supporting the Blob API. But it seems that it tries to load file in RAM and that even hangs my system. Did anyone come across such problem what were the solutions? Maybe HTML5 is inappropriate here? Timmmm Try

How to test file upload in Laravel 5.2

可紊 提交于 2019-11-28 17:13:16
Im trying to test an upload API but it fails every time: Test Code : $JSONResponse = $this->call('POST', '/upload', [], [], [ 'photo' => new UploadedFile(base_path('public/uploads/test') . '/34610974.jpg', '34610974.jpg') ]); $this->assertResponseOk(); $this->seeJsonStructure(['name']); $response = json_decode($JSONResponse); $this->assertTrue(file_exists(base_path('public/uploads') . '/' . $response['name'])); file path is /public/uploads/test/34610974.jpg Here is My Upload code in a controller : $this->validate($request, [ 'photo' => 'bail|required|image|max:1024' ]); $name = 'adummyname' .

How do i secure a web server's image upload directory?

雨燕双飞 提交于 2019-11-28 17:06:24
For my web application, people can upload images from a web form to my web server. What should I set the CHMOD settings for that image upload directory so that people can upload images (from the web server) to that directory but not execute any files they upload for security reasons. Would the chmod settings be? : chmod 744 directory/ There are two possible meanings for "executable" in this context, and both are things you need to configure against. An executable binary file that may run from the command line by typing the file's name into a shell A file that may be read and processed as

Retrofit 2 file down/upload

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 17:03:18
I'm trying to down/upload a file with retrofit 2 but can't find any tutorials examples on how to do so. My code for downloading is: @GET("documents/checkout") public Call<File> checkout(@Query(value = "documentUrl") String documentUrl, @Query(value = "accessToken") String accessToken, @Query(value = "readOnly") boolean readOnly); and Call<File> call = RetrofitSingleton.getInstance(serverAddress) .checkout(document.getContentUrl(), apiToken, readOnly[i]); call.enqueue(new Callback<File>() { @Override public void onResponse(Response<File> response, Retrofit retrofit) { String fileName = document

Best way to upload multiple files from a browser

筅森魡賤 提交于 2019-11-28 16:05:47
I'm working on a web application. There is one place where the user can upload files with the HTTP protocol. There is a choice between the classic HTML file upload control and a Java applet to upload the files. The classic HTML file upload isn't great because you can only select one file at a time, and it's quite hard to get any progress indication during the actual upload (I finally got it using a timer refreshing a progress indicator with data fetched from the server via an AJAX call). The advantage: it's always working. With the Java applet I can do more things: select multiple files at

HTML: How to limit file upload to be only images?

☆樱花仙子☆ 提交于 2019-11-28 15:32:16
问题 With HTML, how do I limit what kind of filetypes can be uploaded? To easy the user experience, I want to limit file uploads to be only images (jpeg, gif, png). <form method="post" action="..." enctype="multipart/form-data"> <label for="image">Photo</label> <input name="image" type="file" /> </form> 回答1: HTML5 says <input type="file" accept="image/*"> . Of course, never trust client-side validation: Always check again on the server-side... 回答2: HTML5 File input has accept attribute and also

How do I test a file upload in rails?

给你一囗甜甜゛ 提交于 2019-11-28 15:22:15
I have a controller which is responsible for accepting JSON files and then processing the JSON files to do some user maintenance for our application. In user testing the file upload and processing works, but of course I would like to automate the process of testing the user maintenance in our testing. How can I upload a file to a controller in the functional testing framework? animal Searched for this question and could not find it, or its answer on Stack Overflow, but found it elsewhere, so I'm asking to make it available on SO. The rails framework has a function fixture_file_upload ( Rails 2

change button text in js/ajax after mp4 =>mp3 conversion in php

左心房为你撑大大i 提交于 2019-11-28 14:50:55
I am working on html table rows (which is two at this moment) as shown below in which on button click: => JS/jQuery code is called (where Go text changes to Converting ) => and then convert.php script through AJAX where conversion of mp4 into mp3 happens. html/php code: <?php foreach ($programs as $key => $program) { ?> <tr data-index="<?php echo $key; ?>"> <td><input type="submit" id="go-btn" name="go-button" value="Go" data-id="<?php echo $key; ?>" ></input></td> </tr> <?php }?> convert.php: $f = $mp4_files[$_POST['id']]; $parts = pathinfo($f); switch ($parts['extension']) { case 'mp4' :

File upload with Javascript without user intervention

时间秒杀一切 提交于 2019-11-28 14:41:17
I have a Firefox component for PDF signing that I invoke via Javascript. The problem is that this component outputs the signed PDF as a file on the user's filesystem - there is no way to get a byte[], stream or similar. I need to post this signed PDF file back to the server. Is it possible to do this in plain Javascript, without additional Firefox components? Nick Craver You can't do this without under intervention, this would he a huge security hole. Think about visiting a webpage and it being able to grab and upload any of your files without you doing a thing...you can see how this would be