upload

How can I know a number of uploaded files with PHP?

狂风中的少年 提交于 2019-11-29 17:09:13
I have a form with several input type="file" tags. How can I know on the server side amount of files uploaded by the user. He can upload 3 files, or may be 5 files, 1 or even nothing. I need to know how much files user have uploaded. Sandeepan Nath If you are having input upload tags with name like file1 , file2 then if($_FILES['file1']['size'] > 0) echo "User uploaded some file for the input named file1" Now for many files (looking at the output you are having), run a foreach loop like this:- $cnt=0; foreach($_FILES as $eachFile) { if($eachFile['size'] > 0) $cnt++; } echo $cnt." files

Determining MIME Type of MAC upload stream file

时光总嘲笑我的痴心妄想 提交于 2019-11-29 16:59:15
I have a simple web form that sends and email out via .NET C#. Additionally there is an ASP UPLOAD ctrl from which I create a memory stream and attach the stream to the Mail Message...ie no need to save file to file system. ISSUE: When MAC users dont inlcude extensions on their uploaded files (I am testing for PostedFile.ContentType to determine the file and/or appropriate extension, allowable files RTF, TXT, PDF, DOC, DOCX) it seems like the ContentType comes back as "application/octet"...this makes some sense to me w/o an extension as required by PCs but; still unclear on weather reading the

How can I upload an embedded image with JavaScript?

强颜欢笑 提交于 2019-11-29 16:37:09
I'd like to build a simple HTML page that includes JavaScript to perform a form POST with image data that is embedded in the HTML vs a file off disk. I've looked at this post which would work with regular form data but I'm stumped on the image data. JavaScript post request like a form submit Joe Coder ** UPDATE ** Feb. 2014 ** New and improved version available as a jQuery plugin: https://github.com/CoeJoder/jquery.image.blob Usage: $('img').imageBlob().ajax('/upload', { complete: function(jqXHR, textStatus) { console.log(textStatus); } }); Requirements the canvas element (HTML 5) FormData

Parsing an uploaded CSV file and storing data to database

社会主义新天地 提交于 2019-11-29 16:35:07
I want the following functionality using php I have a csv file. Each file corresponds to a row in my database There is a html form that will allow me to choose the csv file. Then once the form is submitted, I must parse the csv file and insert data into the db accordingly How do I go about doing this ? Pascal MARTIN Reading a CSV file can generally be done using the fgetcsv function (depending on your kind of CSV file, you might have to specify the delimiter, separator, ... as parameters) Which means that going through you file line by line would not be much harder than something like this :

Django ajax upload image

妖精的绣舞 提交于 2019-11-29 16:32:42
I try to upload image, using Ajax without django forms. It not return errors. Everything it's ok, it save in database "name" and "description" but not save "image" :( My code: views.py def add(request): articles = Article.objects.all() if request.method == 'POST': if request.is_ajax(): name = request.POST.get('name') description = request.POST.get('description') icon = request.FILES.get('icon') article_new = Article( name=name, description=description, icon=icon ) article_new.save() return render_to_response('home.html', {'articles':articles}, context_instance=RequestContext(request)) models

Best method to generate unique filenames when uploading files PHP [duplicate]

≡放荡痞女 提交于 2019-11-29 16:06:35
问题 This question already has an answer here: Unique and temporary file names in PHP? 9 answers Can any one suggest the best practice to generate unique file names for file uploads to avoid duplicate Entries? Thanks In Advance. 回答1: I usually either create a UID using uniqid() function for the filename or create a folder with the name of the username who is uploading the file and leave the original filename. The disadvantage of the first one is that you will have to save the original filename

Restrict File Type and size in PHP form upload

不打扰是莪最后的温柔 提交于 2019-11-29 16:05:52
Hi all I have found some really good code over on http://apptools.com thats helped me create a form that allows users to enter there details upload a file and it then emails it to me automatically which is great. I just wondered if you knew how I could restrict the file types to doc, pdf, psd, ai, jpg, bmp and maybe a few more in the future and also restrict it to 5mb in size. The code I have is below: <?php if(!isset($_POST['Submit'])){ echo "error; you need to submit the form!"; } else { $to="my@email.com"; $subject="Subject header"; $enquiry = $_POST['message2']; $company = $_POST['company2

Passing $_FILES or $_POST to a new page with PHP

吃可爱长大的小学妹 提交于 2019-11-29 15:59:13
I am currently building a new part of an existing script for a client. Currently after a users fills in some account creation info they are directed to a page where they can upload a file and send it, sort of like a file sharing network. The passing of the $_POST variables that are sent / created isn't the issue, what I am trying to do is allow them to create an account and upload a file all from one form. So the process will be fill in form goes to createaccount.php create account, get new accountID attach to other info from original post send to the upload page to upload file automatically

Twitter API -> updating profile bg image with php

自古美人都是妖i 提交于 2019-11-29 15:47:22
问题 So far I have been trying to update the twitter profile bg image thr the twitter api with php... and without success Many examples on the web, including this one: Updating Twitter background via API and this one Twitter background upload with API and multi form data do not work at all, most ppl throw out answers without actually testing the code. I found that directly submit the image to the twitter.com thr html form, it will work: <form action="http://twitter.com/account/update_profile

upload image from iPhone application

最后都变了- 提交于 2019-11-29 15:46:15
问题 i am trying to upload a image to server from iPhone application PHP code for upload image is following if(isset($_POST['insertImage'])) { //INSERT IMAGE ------------------- $method=safeData($_POST['insertImage']); if($method=='true') { if(isset($_POST['userId'])) { if(isset($_FILES['imageFile'])) { if($_FILES['imageFile']['type']=="image/gif" || $_FILES['imageFile']['type']=="image/bmp" || $_FILES['imageFile']['type']=='image/jpeg' || $_FILES['imageFile']['type']=='image/jpg' || $_FILES[