upload

Remove file extension on file upload

不问归期 提交于 2019-12-01 00:18:57
I'm writing the code for a website right now that's uploads images and then displays them gallery style. What I would like to happen is for the file name of the image to be entered into the site's database as the name of the image. However, just using $_FILES['images']['name']; gives me the file name but with the file extension attached at the end. How would I remove the file extension so I can use the file name by itself? You can use the pathinfo() function ( docs ). $example = "my_file.jpeg"; $filename = pathinfo($example, PATHINFO_FILENAME); echo $filename; // my_file Just use preg_replace:

Codeigniter multiple file upload paths

僤鯓⒐⒋嵵緔 提交于 2019-11-30 23:45:54
I'm building an app which needs to take uploaded files and put them in separate directories for thumbnails and fullsize images. But $config['upload_path'] = './uploads/'; only allows me to select one upload path. How do I define two or more upload paths? Actually all you need to do is "re-initialize" the upload class. Codeigniter does not allow you to call the class twice with new parameters (it ignores the second request), however you can tell the class to manually load new parameters. Here are the basics: (notice the line "$this->upload->initialized($config)" This is the key. // this is for

PHP Send local file by cURL

▼魔方 西西 提交于 2019-11-30 23:41:14
Im trying to send a local file by client curl app. I found some examples to do that with files from a form. In my case, I have no form, but a local file. $fileName = $_SERVER["DOCUMENT_ROOT"]."/www/images/test.pdf"; if(!file_exists($fileName)) { $out['status'] = 'error'; $out['message'] = 'File not found.'; exit(json_encode($out)); } $data = array('name' => 'Foo', 'file' => '@'.$fileName); $cURL = curl_init("http://myapi/upload-images"); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_POST, 1); curl_setopt($cURL, CURLOPT_POSTFIELDS, $data); $response = curl_exec(

Compress files (client side) and upload

倾然丶 夕夏残阳落幕 提交于 2019-11-30 22:51:01
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" enctype="multipart/form-data"> <input style="display:none" type="file" name="singlezipfile"> <input

Creating a custom upload progress bar

南笙酒味 提交于 2019-11-30 21:17:34
I have seen all the upload progress bar plugins, widgets, etc. – they all suck. They're either too bulky with too much useless code or they don't work. What I want to know is where I can read up on how to display an easy upload progress indicator. Most browsers have a status progress bar on them below, but it isn't very professional to use just that when dealing with clients. How does the browser do it? I want to know the internals of how the browser works with for indicating the status of something uploading so that maybe I can make something using PHP & jquery. Thanks. Since you want to use

PHP AJAX file upload

爷,独闯天下 提交于 2019-11-30 21:12:33
问题 i've looked all over stackoverflow and the general internet and i can't find a simple AJAX file uploader (Just form submission). The ones i have found aren't flexible enough and don't fit my purpose. If i could ajust this script to file uploads, that would be great: <script type="text/javascript"> function upload(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new

Does fetch support multiple file upload natively?

最后都变了- 提交于 2019-11-30 20:30:50
问题 Summary I am trying to set my FormData properly using javascript. I need to be able to upload jpg/png , but I might need to upload some other file types pdf/csv in the future using fetch. Expected I expect it to append the data to the form Error Working This snippet is working fine: const formData = new FormData(document.querySelector('form')); formData.append("extraField", "This is some extra data, testing"); return fetch('http://localhost:8080/api/upload/multi', { method: 'POST', body:

Best way storing binary or image files

送分小仙女□ 提交于 2019-11-30 20:19:39
What is the best way storing binary or image files? Database System File System Would you please explain , why? There is no real best way, just a bunch of trade offs. Database Pros : 1. Much easier to deal with in a clustering environment. 2. No reliance on additional resources like a file server. 3. No need to set up "sync" operations in load balanced environment. 4. Backups automatically include the files. Database Cons : 1. Size / Growth of the database. 2. Depending on DB Server and your language, it might be difficult to put in and retrieve. 3. Speed / Performance. 4. Depending on DB

How can I upload a file using JavaScript without a postback?

邮差的信 提交于 2019-11-30 20:17:49
问题 I am working on a file upload in ASP.NET. I used <input type=file id=upload> and <input type=button id="btnupload" value="File Upload"> I want to upload the file in JavaScript. The update panel does not work, I do not want it to postback and refresh the page. thanks but If you have code related to fileUpload in javascript then send me. please help me. 回答1: You can use jQuery and jQuery form plugin. I used this combination for few project and i had no problems, even for big files (10mb) <form

Remove file extension on file upload

柔情痞子 提交于 2019-11-30 19:28:38
问题 I'm writing the code for a website right now that's uploads images and then displays them gallery style. What I would like to happen is for the file name of the image to be entered into the site's database as the name of the image. However, just using $_FILES['images']['name']; gives me the file name but with the file extension attached at the end. How would I remove the file extension so I can use the file name by itself? 回答1: You can use the pathinfo() function (docs). $example = "my_file