Ask a Question related to PHP Development, Design and Development.
-
Lo Dolce Pesca #1
binary data
Greets,
Register globals are to OFF - however the files will not upload.
Thanking all in advance.
TR
...............
<?
if ($submit) {
// connect to the database
// (you may have to adjust the hostname,username or password)
MYSQL_CONNECT("localhost","root","mypass");
mysql_select_db("mydb");
$uploadfile = $_FILES['form_data']['tmp_name'];
$uploadname = $_FILES['form_data']['name'];
$uploadtype = $_FILES['form_data']['type'];
$uploaddesc = $_POST['desc'];
// Open file for binary reading ('rb')
$tempfile = fopen($uploadfile,'rb');
// Read the entire file into memory using PHP's
// filesize function to get the file size.
$filedata = fread($tempfile,filesize($uploadfile));
// Prepare for database insert by adding backslashes
// before special characters.
$filedata = addslashes($filedata);
// Create the SQL query.
$sql = "INSERT INTO binary_data SET
filename = '$uploadname',
filetype = '$uploadtype',
description = '$uploaddesc',
bin_data = '$filedata'";
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
echo "<br>";
echo "<a href=\"getdata.php?id=$id\">Click to view file</a>";
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
?>
<form method="post" action="<?php echo $PHP_SELF; ?>"
enctype="multipart/form-data">
<p>File Description:<br>
<input type="text" name="desc" size="40">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
Lo Dolce Pesca Guest
-
Binary data transfer
Hi i`m asked this question in several other websites but i don`t give an answer, ihope to give a right answer here. I need to use the... -
Webservices & binary data?
Hi, We have a database that stores binary data such as word documents. Can these documents be delivered over Webservices by other applications... -
Freehand Binary Data
When printing from my Freehand 9, I often get a message "Page contains EPS pictures which include binary data" What does this mean? I also have had... -
ASP Binary data transformation
Hello, I'm using ADODB.Stream to open a binary file on the server and write it down to the browser using Response.BinaryWrite. It's working fine,... -
Is $data binary or ascii?
Say I have a variable $data that has file contents in it. Is there a way to tell if it is binary or ascii? if($data =~ ???) { print "It is binary... -
Andy Hassall #2
Re: binary data
On Thu, 15 Apr 2004 21:35:13 -0400, "Lo Dolce Pesca" <herefishyfishy@spam.org>
wrote:
>Register globals are to OFF - however the files will not upload.You've forgotten to actually execute the query.> // Prepare for database insert by adding backslashes
> // before special characters.
> $filedata = addslashes($filedata);
>
> // Create the SQL query.
> $sql = "INSERT INTO binary_data SET
> filename = '$uploadname',
> filetype = '$uploadtype',
> description = '$uploaddesc',
> bin_data = '$filedata'";
--> $id= mysql_insert_id();
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
[url]http://www.andyh.co.uk[/url] / [url]http://www.andyhsoftware.co.uk/space[/url]
Andy Hassall Guest



Reply With Quote

