SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: help with mysql and file upload
-
May 20, 2003, 04:43 #1
- Join Date
- Jan 2003
- Posts
- 232
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
help with mysql and file upload
HI,
Can any one point me to a script. That stores file uploaded to a mysql database.
Thanks
-
May 20, 2003, 04:54 #2
- Join Date
- Nov 2000
- Location
- New York
- Posts
- 765
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I know it's not what you're looking for, but Kevin's book has a chapter at the end describing exactly that (and it includes all the code for it).
-
May 20, 2003, 06:28 #3
- Join Date
- Jul 2002
- Location
- South-West UK
- Posts
- 100
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just finished writing a complete set of scripts if you'd like them?
Let me know and I can mail them to you.
-
May 20, 2003, 21:08 #4
- Join Date
- Jan 2003
- Posts
- 232
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I got a small file upload script but when I try uploading more than 1 MB it's not working why does any one know
-
May 20, 2003, 21:14 #5
- Join Date
- Aug 2002
- Posts
- 178
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The limit might be set to 1MB.
http://www.php.net/manual/en/function.ini-set.php has more on this, you might not be able if you are on a shared server to set this though.
-
May 20, 2003, 21:23 #6
- Join Date
- Jan 2003
- Posts
- 232
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No it's not set
----------------------------------------
This is the script
----------------------------------------------------
<?php
$dbx = @mysql_connect("localhost", "", "" );
if (!$dbx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! @mysql_select_db("abc" ) ) {
echo( "<p>Unable to locate the " .
"database at this time.</p >" );
exit();
}
?>
<HTML>
<HEAD>
<TITLE>CBN WORLD UPLOAD PAGE</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<?php
require("setup.php" );
if($doupload) {
if($ADMIN[RequirePass] == "Yes" ) {
if($password != "$ADMIN[Password]" ) {
?>
<P><CENTER><B><FONT FACE="Verdana">Error</FONT></B></CENTER></P>
<P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
<TR>
<TD WIDTH="100%" BGCOLOR="#000000">
<TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
<TR>
<TD COLSPAN="2" BGCOLOR="#ffffff">
<FONT COLOR="#000000" SIZE="-1" FACE="Verdana">Invalid Password</FONT></TD>
</TR>
</TABLE></TD>
</TR>
</TABLE></CENTER></P>
</BODY>
</HTML>
<?php
exit();
}
}
$num = 0;
while($num < $ADMIN[UploadNum]) {
$num++;
$picture = "fileup$num"."_name";
$picture1 = $$picture;
$picture2 = "fileup$num";
$picture3 = $$picture2;
if($picture3 != "none" ) {
$filesizebtyes = filesize($picture3);
$ok = 1;
if($filesizebtyes < 10) {
$error .= "Error uploading (file size lower than 10 bytes) for file $num<BR>";
$ok = 2;
}
if(file_exists("$ADMIN[directory]/$picture1" ) OR $ok == 2) {
$error .="File name already exists for file $num<BR>";
} else {
$sql = "INSERT INTO image (file) Values ('$ADMIN[directory]/$picture1')";
copy ($picture3, "$ADMIN[directory]/$picture1" );
mysql_query($sql);
$error .="File $num has been uploaded<BR>";
}
}
}
if(!$error) {
$error .= "No files have been selected for upload";
}
?>
<P><CENTER><B><FONT FACE="Verdana">Status</FONT></B></CENTER></P>
<P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
<TR>
<TD WIDTH="100%" BGCOLOR="#000000">
<TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
<TR>
<TD COLSPAN="2" BGCOLOR="#ffffff">
<FONT COLOR="#000000" SIZE="-1" FACE="Verdana"><?php echo $error; ?></FONT></TD>
</TR>
</TABLE></TD>
</TR>
</TABLE></CENTER></P>
<P><CENTER> </CENTER></P>
<P><CENTER> </CENTER></P>
<P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by/B> <A HREF="<A href="http://www.phpscriptcenter.com/uploader.php">http://www.phpscriptcenter.com/uploader.php" TARGET="_blank">Uploader</A> Version 1.1</FONT></CENTER>
</BODY>
</HTML>
<?php
exit();
} else {
$num = 0;
while($num < $ADMIN[UploadNum]) {
$num++;
$html .= "<TR>
<TD WIDTH=\"25%\" BGCOLOR=\"#295e85\">
<FONT COLOR=\"#ffffff\" SIZE=\"-1\" FACE=\"Verdana\">File $num/FONT></TD>
<TD WIDTH=\"75%\" BGCOLOR=\"#ffffff\">
<INPUT NAME=\"fileup$num\" TYPE=\"file\" SIZE=\"25\">
</TD> ";
}
?>
<FORM ENCTYPE="multipart/form-data" ACTION="uploader.php" METHOD="POST">
<P><CENTER><B><FONT FACE="Verdana">Upload</FONT></B></CENTER></P>
<P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD WIDTH="100%" BGCOLOR="#000000">
<TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
<TR>
<TD COLSPAN="2" BGCOLOR="#295e85">
<B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Select Files</FONT></B></TD>
</TR><?php echo $html; ?>
</TABLE></TD>
</TR>
</TABLE></CENTER></P>
<?php
if($ADMIN[RequirePass] == "Yes" ) {
?>
<P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD WIDTH="100%" BGCOLOR="#000000">
<TABLE WIDTH="300" BORDER="0" CELLSPACING="1" CELLPADDING="2">
<TR>
<TD WIDTH="33%" BGCOLOR="#295e85">
<B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Password/FONT></B></TD>
<TD WIDTH="67%" BGCOLOR="#ffffff">
<INPUT NAME="password" TYPE="password" SIZE="25">
</TD>
</TR>
</TABLE></TD>
</TR>
</TABLE></CENTER></P>
<?php
}
?>
<P><CENTER><INPUT NAME="doupload" TYPE="submit" VALUE="Upload Files"></CENTER></FORM>
<P><CENTER> </CENTER></P>
<P><CENTER> </CENTER></P>
<P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by/B> <A HREF="<A href="http://www.phpscriptcenter.com/uploader.php">http://www.phpscriptcenter.com/uploader.php" TARGET="_blank">Uploader</A> Version 1.1</FONT></CENTER>
</BODY>
</HTML>
<?php
exit();
}
?>
I hope anyone of you can help me
-
May 20, 2003, 21:52 #7
- Join Date
- Jan 2003
- Posts
- 232
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
With the above script when I try uploading a file that is big this is the error it gives
No files have been selected for upload
Even though I select the file it gives the error
Bookmarks