user Posted November 27, 2003 Report Share Posted November 27, 2003 Kā uztaisīt, lai var uploadot bildi un shiis bides nosaukumu ievietot mysql datu baazee?? Link to comment Share on other sites More sharing options...
AntiXakep Posted November 28, 2003 Report Share Posted November 28, 2003 Pajauta googlei vai ari pacheko shito! http://manlix.ru/new/?section=articles&sub...dent=UploadFile Link to comment Share on other sites More sharing options...
Kaspars Posted November 28, 2003 Report Share Posted November 28, 2003 Kaadu laiku vienam cilveekam izpaliidzeeju ieksh ProgrammingTalk.com, kur bija nepiecieshams upload scripts. Tev pasham ir jaapievieno klaat mysql_query, kas pievieno faila nosaukumu datubaazei: <?php // Set the upload place, after your document root directory $upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/upload/"; // An array of allowed file types $file_types = array( 'audio/mpeg' => 'mp3', 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png', 'image/x-dwg'=> 'dwg' ); if (isset($_POST[submit])) { // Write as many file upload // inputs as user wanted $file_amount = $_POST['file_amount']; // Check if not amount of files not empty if ( empty($file_amount) ) { print "<font color='#990000'>You did not select the amount of files you want to upload!\n " . "Please <a href='java_script_:history.back(-1)'>go back</a> and select!</font>"; return; } $counter = 1; while ($counter <= $file_amount) { $foto_input .= "$counter. file: <input name='filename[$counter]' type='file'><br />\n"; $counter++; } // Generate an html output // where to display the file // upload fields print "<form enctype='multipart/form-data' action='$PHP_SELF' method='post' name='upload_form'> <table width='100%' border='0' align='center'> <tr><td> <li>Upload path: $upload_dir</li>\n <li>Amount of files to upload: <b>$file_amount</b></li>\n </td></tr>\n <tr><td>$foto_input</td></tr>\n <tr><td><input type='submit' name='upload' value='Upload Files'></td></tr>\n </table>\n </form>\n"; } else { // Generate the form // for user to select how many uploads he // wants to do. print "<form name='gallery_setup' method='post' action='$PHP_SELF'>" . "Number of photos to upload:" . " <input name='file_amount' type='text' id='file_amount' size='10'>" . " <input type='hidden' name='MAX_FILE_SIZE' value='300000000'>" . " <input name='submit' type='submit' id='submit' value='submit'> " . "</form>"; } if (isset($_POST[upload])) { // Get the upload file array // and upload them to a destination // by looping through that array // Get the variables from previous form $up_files = $_FILES['filename']; $counter = 0; // Start the file upload to server while($counter <= count($up_files)) { if($up_files['size'][$counter] > 0) { // Read the mime type of current file $filetype = $up_files['type'][$counter]; $filename = $up_files['name'][$counter]; $tempname = $up_files['tmp_name'][$counter]; if (!array_key_exists($filetype, $file_types)) { print "<font color='#990000'>File <b>$filename</b> of type <b>$filetype</b> is not valid for upload!</font><br />"; } else { $upload_file = $upload_dir . $filename; // Upload the files move_uploaded_file($tempname, $upload_file); // Print the uploaded file print "<font color='#009900'>File <b>$filename</b> uploaded... new location: <b>$upload_file</b></font><br />"; } } $counter++; } // End if upload } ?> Ceru, ka izpaliidzeeju, Kaspars Link to comment Share on other sites More sharing options...
Recommended Posts