Jump to content

Recommended Posts

I want to extract data from multiple uploads. I got a script but I'm making some type of mistake because it's not working right. I don't need any of these files saved on the server just need to extract the data. I got it working for one upload, but not multi.

 

function CheckFile()
{
for($i=0; $i < count($_FILES['file']['tmp_name']);$i++)
{
	if ($_FILES["file"]["type"][$i] != "application/octet-stream")
	{	
		continue;
	}
	if($_FILES["file"]["size"][$i] > 1000)
	{
		continue;
	}
	if(substr($_FILES["file"]["name"][$i],-4) != ".lnd")
	{
		continue;
	}
	if ($_FILES["file"]["error"][$i] > 0)
	{
		continue;
	}
	if (is_uploaded_file($_FILES['file']['tmp_name'][$i]))
	{
		$contents = file_get_contents($_FILES['file']['tmp_name'][$i]);
		echo "Contents " . $n . "<br>" . $contents;
		$fileData .= $contents;
	}

}

CreateMap($fileData);
}

 

echo "<form enctype='multipart/form-data' action='zminerupload.php?check=true' method='POST'>
<input type='hidden' name='MAX_FILE_SIZE' value='1000' />
Choose a file to upload:<br> 
<input type='file' name='file[]' id='file[]' /><br>
<input type='file' name='file[]' id='file[]' /><br>
<input type='file' name='file[]' id='file[]' /><br>
<input type='file' name='file[]' id='file[]' /><br>
<input type='submit' name = 'submit' value='Upload File'>
</form>";

 

So where did I goof up?

Link to comment
https://forums.phpfreaks.com/topic/177145-combing-data-from-multi-uploads/
Share on other sites

with this if statement

if($_FILES["file"]["size"][$i] > 1000)
	{
		continue;
	}

 

unless all your files are below 1000 bytes (less than a kilobyte!) it will skip every step after that.

 

remember, file is in bytes, so you may want to change that

Well used the original script with a few modifications and noticed I was able to get it successfully uploaded. When I tried to extract the data without it uploading it was too much for it. So I'm fine with just uploading it, but I want to give it set names.

 

map1.txt

map2.txt

map3.txt

map4.txt

 

So how can I rename each upload to those names?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.