svnno****@sourc*****
svnno****@sourc*****
2011年 5月 10日 (火) 00:36:54 JST
Revision: 38
http://sourceforge.jp/projects/smartupload/svn/view?view=rev&revision=38
Author: hryksbt
Date: 2011-05-10 00:36:53 +0900 (Tue, 10 May 2011)
Log Message:
-----------
アップロードファイルがDBに登録されないバグを修正
Modified Paths:
--------------
trunk/SmartUpload/upload_file.php
trunk/SmartUpload/upload_form.php
-------------- next part --------------
Modified: trunk/SmartUpload/upload_file.php
===================================================================
--- trunk/SmartUpload/upload_file.php 2011-05-08 15:36:30 UTC (rev 37)
+++ trunk/SmartUpload/upload_file.php 2011-05-09 15:36:53 UTC (rev 38)
@@ -2,7 +2,7 @@
/*
* SmartUpload/upload_file.php
* @author Hiroyuki Shibata
- * 2011/05/06
+ * 2011/05/09
* Rev 1.0
*
*/
@@ -25,19 +25,19 @@
$updir = "./data/";
- $contentname = $_REQUEST["category"];
+ $contentname = $_REQUEST["contents"];
$filename = $_FILES['upfile']['name'];
- $filesize = filesize($_FILES['upfile']['tmp_name']);
+ $filesize = $_FILES['upfile']['size'];
$username = $_SESSION["id"];
$category = $_REQUEST["category"];
- $commnet = $_REQUEST["comment"];
+ $comment = $_REQUEST["comment"];
- if(move_uploaded_file($_FILES['upfile']['tmp_name'], $updir.$filename)==FALSE) {
+ if(move_uploaded_file($_FILES['upfile']['tmp_name'], $updir."$filename")==FALSE) {
print("Upload failed");
print($_FILES['upfile']['error']);
- } else {
+ } elseif ($_SESSION["id"]) {
print("<b> $filename </b> is uploaded.<br />");
print("size = "."$filesize"." bytes<br />");
@@ -52,18 +52,43 @@
data_size,
category,
comment
- ) VALUES (?, ? ,now() ,? ,? ,? ,?)");
+ ) VALUES (?, ?, now(),? ,? ,? ,? )");
$stmt->bindParam(1, $contentname);
$stmt->bindParam(2, $filename);
$stmt->bindParam(3, $username);
$stmt->bindParam(4, $filesize);
$stmt->bindParam(5, $category);
- $stmt->bindParam(6, $commnet);
+ $stmt->bindParam(6, $comment);
$stmt->execute();
print('<br>');
+ } else {
+
+ print("<b> $filename </b> is uploaded.<br />");
+ print("size = "."$filesize"." bytes<br />");
+
+ // データベース処理
+ $stmt = $db->prepare(
+ "INSERT INTO data_info (
+ contentname,
+ filename,
+ uploaddate,
+ data_size,
+ category,
+ comment
+ ) VALUES (?, ?, now() ,? ,? ,? )");
+
+ $stmt->bindParam(1, $contentname);
+ $stmt->bindParam(2, $filename);
+ $stmt->bindParam(3, $filesize);
+ $stmt->bindParam(4, $category);
+ $stmt->bindParam(5, $comment);
+ $stmt->execute();
+
+ print('<br>');
+
}
?>
Modified: trunk/SmartUpload/upload_form.php
===================================================================
--- trunk/SmartUpload/upload_form.php 2011-05-08 15:36:30 UTC (rev 37)
+++ trunk/SmartUpload/upload_form.php 2011-05-09 15:36:53 UTC (rev 38)
@@ -2,7 +2,7 @@
/*
* SmartUpload/upload_form.php
* @author Hiroyuki Shibata
- * 2011/05/5
+ * 2011/05/09
* Rev 1.0
*
*/
@@ -18,7 +18,7 @@
<h2>アップロード</h2>
<form method="post" enctype="multipart/form-data" action="upload_file.php">
<pre>
-コンテンツ名 :<input type="text" name="mail"> ※ 全角32文字以内<br>
+コンテンツ名 :<input type="text" name="contents"> ※ 全角32文字以内<br>
カテゴリ :<select name="category">
<?php
require_once("include/database.php");