Note that there are some explanatory texts on larger screens.

plurals
  1. POdirectory upload php some dirs work, some don't
    primarykey
    data
    text
    <p>I have 2 questions, first one:</p> <p>I'm trying to upload all the files in a specific folder and move them to the user his private folder with PHP. My current code:</p> <pre><code>$count = 0; if ($_SERVER['REQUEST_METHOD'] == 'POST'){ foreach ($_FILES['files']['name'] as $i =&gt; $fname) { if (strlen($_FILES['files']['name'][$i]) &gt; 1) { if (move_uploaded_file($_FILES['files']['tmp_name'][$i], 'users/' . $currentUser . '/uploads/' . $fname)) { $count++; } } } } </code></pre> <p>and</p> <pre><code>&lt;div id="divUpload"&gt; &lt;form method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="files[]" id="files" mozdirectory="" directory="" webkitdirectory=""&gt; &lt;input class="button" type="submit" value="Upload" /&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>The $count is used later to check if any files were uploaded.</p> <p>This code works flawlessly on my localhost system but it doesn't seem to work on my ubuntu server on certain folders. For example: a folder with 20 images inside of it works just fine, while a folder with only 1 image can already give me an error.</p> <p>I've updated my php.ini file and made these changes:</p> <pre><code>upload_max_filesize = 199M max_file_uploads = 100 </code></pre> <p>I will be the only one using this website and it's only possible to connect to it from my own network so don't worry about security. My www-data user also has full access to the folders on my server so I don't think it's a permission thing either.</p> <p>When I try to debug my code using the php.ini-development it gives me the error</p> <pre><code>Warning: Invalid argument supplied for foreach() in /var/www/upload.php on line 14 </code></pre> <p>and when I try to var_dump() it, it returns NULL as if no files were uploaded at all... Did I make a mistake somewhere? I'm pretty confused because it works sometimes without any problems...</p> <p><strong>Second question:</strong> </p> <p>I read somewhere that the upload_max_filesize in php.ini is limited by the memory_limit. Is this true? </p> <p>This project I'm making is a home NAS and I've managed to make my code run smoothly with a total memory_limit of 200M. Does this mean I won't be able to upload file which are larger then 200MB??? Why does this work on my localhost aswell then? (It uses the same 200M memory_limit constraint)</p> <p>Thanks, S</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload