Multiple Files upload PHP in Ubuntu - php

I am trying to upload multiple files (tsv,csv) using PHP. The HTML and PHP script is written below. It works for me when running with XAMPP on Windows. However, on Ubuntu,when trying upload 2 files at a time (one is tsv, the other is csv) I can only upload one file at a time, but not two. I am not sure what the reasons are but it seems that there is something needed to be done with the server settings.
The code below won't work if I upload both tsv and csv but it works with other file types.
<form action='' method='post' enctype="multipart/form-data">
<input type='file' name='usrfile[]'/>
<input type='file' name='usrfile[]'/>
<input type='submit' name='submit'/>
</form>
<?php
if(isset($_POST["submit"])){
for($i=0;$i<=1;$i++){
move_uploaded_file($_FILES["usrfile"]["tmp_name"][$i],"upload/" . $_FILES["usrfile"]["name"][$i]);//upload the ecwave file to the upload/ folder
}
}
?>

Make a look at the manual.
There is a max_file_uploads setting, which restricts the number of allowed files per form.

Related

Multiple upload but upload files separately to not overload PHP

I'm currently working on a photoalbum thing on my website and was wondering is there is a way to upload files separately even though I selected multiple files for upload, let me explain:
<form method="post" action="upload.php" enctype="multipart/form-data">
<input name='uploads[]' type="file" accept="image/*" multiple>
<input type="submit" value="Send">
</form>
<?php
$y=count($_FILES['uploads']);
for($x=0;$x<$y;$x++) {
echo $_FILES['uploads']['name'][$x];
echo "<br>";
}
?>
So I've got these simple lines of code. And basically (As you can see) you can upload multiple files. But let's say that that my 'upload_max_filesize' is at 8M. I can only select 4 images of 2MB each to upload successfully, otherwise I overwrite the max upload size. My question is, is there a PHP way to keep the form structure the same but let the script handle one file at the time so I can upload 5.000 files from 5MB's each for example?

How to upload .ipa file to server in html?

I am able to upload other file types like .txt, .png, .apk using
<form action="index1.php" method="post" name = "mySuperForm"
enctype="multipart/form-data">
<input type="text" placeholder="Application Name" name="appname">
<input type="text" placeholder="Version Number" name="appversion">
Application File: <input style = "width:auto" type="file" name="file" id="file"><br>
</form>
But, when I try to upload a .ipa file, I can't grab the application name or version number on index1.php (the page I am posting to)using $_POST. However, if I upload a different file type, I can. It's as if nothing is getting posted if I try to upload an ipa file, like the html is failing on that line. I am using my localhost, wamp server. Any advice?
Without seeing your handling PHP, it's a bit difficult to diagnose, but here are a few potential items that may point you in the right direction:
Does the .IPA file exceed the *post_max_size* or *upload_max_filesize* as defined in your PHP configuration?
Try var_dump($_FILES); to see if your script is seeing the files there.
I think this is happening because the file is too big and the request is being truncated by the web server, so PHP would not be able to access any form fields because the request was not completed. How large is the ipa file? You might need to adjust your maximum post size. The default is usually 4 MB.

PHP ftp_put files are uploading, but I cannot find them on my server

so I am the webmaster/in charge collecting the files for a music video contest. The problem is I only know HTML, CSS, limited PHP, and some Actionscript 2. I need to be able to allow people to upload large files to my server (the videos they are submitting) but I am unable to find a way to do that. I was wondering if anyone had any suggestions of an upload system that work work for me. I have tired PHP's ftp_put but the files seem to be too large for it to handle. Thanks
I'm not sure if this will work for very large files, but I do some image uploading using a form and file inputs like so:
HTML
<form method="post" action="upload.php">
<input type="file" name="file" />
</form>
PHP
move_uploaded_file($_FILES['file']['tmp_name'], $server_path . $new_file_name);
You can also upload multiple files like so:
HTML
<form method="post" enctype="multipart/form-data" action="upload.php">
<input type="file" name="files[]" />
<input type="file" name="files[]" />
<input type="file" name="files[]" />
</form>
PHP
for ($i = 0; $i < count($_FILES['images']['error']); $i++)
{
move_uploaded_file($_FILES['file']['tmp_name'][$i], $server_path . $new_file_name[$i]);
}
I know for example youtube, as well as facebook have a process that uploads the files by parts ... but I don't know how it happens.
Another way would be to create an ftp account for each user and then they can use a program like filezila.
The other way, I think it would be an application in Java.
large files can also be handled by ftp_put, check your settings for upload_max_filesize, post_max_size, max_execution_time, max_input_time, and memory_limit in your php.ini file. These could all affect your file uploading abilities.
The problem with PHP uploading is that typically there's a file size limit and there's a server timeout limit as well, as in if the script is running for so long, it will time out. This becomes a problem in uploading larger files. If you can modify these settings yourself on your server then I suggest you try SWFUpload

How do I make an upload file form to my blog?

I want to upload the files to this address: http://chusmix.com/Imagenes/grupos and I'm trying with this simple this code but it doesn't work:
<form enctype="multipart/form-data" method="post" action="http://chusmix.com/Imagenes/grupos">
Please specify a file:<br>
<input type="file" name="datafile" size="40">
</p>
<div>
<input type="submit" value="Send">
</div>
</form>
Oddly enough, the first result of a Google search yielded this rather helpful tutorial. Why not read it?
Read the PHP manual chapter "Handling file uploads":
http://php.net/manual/en/features.file-upload.php
The way you think uploads work is not the way they work. The form posts to the script you want to handle the request, not the location you want the uploads to be. When you upload a file to Apache, it places that file in the temporary directory of the computer (in Linux, that's /tmp by default).
Your script has to move the file from the temp directory to wherever you want it to be. The manual has plenty of code showing you how.
Make sure the form is loaded via
http://chusmix.com/Imagenes
The browsers wont you allow to upload to a unkown website (Same origin policy).
Edit your form
<form enctype="multipart/form-data" method="post" action="/grupos">

HTML Upload Form will only upload files found in the directory of the PHP file

I have an image uploader that uses the imgur.com API and jQuery's .ajax() function to upload images to their servers. However, if I browse for an image using the <input type="file"/> element of the form, it will only be successful in uploading an image if the image file is found in the same directory as the page.php file that the form is found in (shown below). How can I allow the form to upload images from any directory on my computer?
page.php:
<form action="page.php" method="post">
<input type="file" name="doc" id="doc" /><br/>
<input type="image" src="go.gif" name="submit" id="submit" />
</form>
You've forgotten the enctype="multipart/form-data" attribute on your form tag, for one. Without that, file uploads generally don't work too well.
Beyond that, the server won't really care what directory you're uploading FROM, especially under PHP. The uploaded copy on the server is stored with temporary filename ($_FILES['file']['tmp_name']) that has absolutely nothing to do with the directory/filename on your computer.
Once it's on the server, you'll have to actually move that temporary file somewhere else, as PHP will auto-delete it once the script terminates and you've not handled it yourself. move_uploaded_file() is what's generally used to take of that process.
Perhaps this is the only folder with write-permissions.
I guess it is jquery that is doing the actual posting to http://imgur.com/api/upload as the form is just posting to itself, so my guess is that jquery / javascript can only read files in your web-space and not on your whole hard-drive.

Categories