Jump to content
php.lv forumi

Multiple file upload


ziedinjsh

Recommended Posts

-katram failam, kad norādi/pievieno(postforma) ir jābūt atšķirīgam lauka nosaukumam.

-katru no tiem failiem ciklā laižot ir gan jāsaglabā uz servera gan tā faila identifikātors un ceļš uz failu bāzē.

Tas kā minimums, tad jau var ko tālāk. /man gan liekas, ka šādas problēmas ir risinātas arī agrāk/

Link to comment
Share on other sites

tātad, vairāk vai mazāk ir šādi.. lapa kur izvēlas failus:

<?php

echo "<form id='file_upload' action='fcs/upload2.php' method='POST' enctype='multipart/form-data'>
   <input type='file' name='file' multiple>
   <button>Upload</button>
   <div>Upload files</div>
</form>
<table id='files'></table>";
?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script src="js/jquery.fileupload-ui.js"></script>

<script>
/*global $ */
$(function () {
   $('#file_upload').fileUploadUI({
       uploadTable: $('#files'),
       downloadTable: $('#files'),
       buildUploadRow: function (files, index) {
           return $('<tr><td>' + files[index].name + '<\/td>' +
                   '<td class="file_upload_progress"><div><\/div><\/td>' +
                   '<td class="file_upload_cancel">' +
                   '<button class="ui-state-default ui-corner-all" title="Cancel">' +
                   '<span class="ui-icon ui-icon-cancel">Cancel<\/span>' +
                   '<\/button><\/td><\/tr>');
       },
       buildDownloadRow: function (file) {
           return $('<tr><td>' + file.name + '<\/td><\/tr>');
       }
   });
});
</script> 

 

un šis ir upload:

<?php
session_start();
include ("dbase.php");

$data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_email='".$_SESSION['user_email']."' LIMIT 1"));

$destination_path = "gallery/";
$file = $_FILES['file'];
$user = $data['user_name']."_";
$gallery = $destination_path .$user. basename( $file['file']['name']);

move_uploaded_file($file['file']['tmp_name'], $gallery);

?>

bet nu kā jau nojaušat man failus nepārvieto uz folderi. 100% ka kautkas nav kārtībā.. bet uz sitienu nevaru iebraukt kas!?

Link to comment
Share on other sites

Es teiktu, ka problēma ir starp krēslu un klaviatūru.

Iemācies tak pats vienreiz labot savu kodu. Ja nepārvieto uz folderi, tad pārbaudi vai vispār ir ko pārvietot. Vai ceļš uz folderi, kur pārvieto, ir pareizs, vai ir atļaujas tur kaut ko pārvietot.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...