Problems with File Upload
Posted: Wed May 02, 2007 9:20 am
JayBird | Please use
JayBird | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am currently building a website as a project. The web site needs to upload files to a database. I am using blobs to create my code. The code enters all the information about the file eg, name, file type, etc but it does not physically upload the file. The code I have entered is displayed below. I would assistance if anyone could shed a light on what I am doing wrongCode: Select all
<?php
include("connection.php");
$connection = connect();
$strDesc = $_POST['strDesc'];
$fileUpload = $_POST['fileUpload'];
$fileUpload_name = $_FILES['fileUpload'] ['name'];
$fileUpload_size = $_FILES['fileUpload'] ['size'];
$fileUpload_type = $_FILES['fileUpload'] ['type'];;
// Make sure both a description and
// file have been entered
if(empty($strDesc) || $fileUpload == "none")
die("You must enter both a description and file");
fopen($fileUpload, "r");
//$file_contents = fread($fp, filesize($postfile));
$file_contents = file_get_contents($fileUpload);
//fclose($fp);
$dbQuery = "INSERT INTO myBlobs VALUES ";
$dbQuery .= "(0, '$strDesc', '$file_contents', '$fileUpload_type')";
mysql_query($dbQuery) or die("Couldn't add file to database");
echo "<h1>File Uploaded</h1>";
echo "The details of the uploaded file are shown below:<br><br>";
echo "<b>File name:</b> $fileUpload_name <br>";
echo "<b>File type:</b> $fileUpload_type <br>";
echo "<b>File size:</b> $fileUpload_size <br>";
echo "<a href='getfiles.php'>Add Another File</a>";
?>Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]