Do you know what function (code) to use if I would like to store files like e.g. images and what function to use for showing results?Quote:
Originally Posted by Sheldon
Printable View
Do you know what function (code) to use if I would like to store files like e.g. images and what function to use for showing results?Quote:
Originally Posted by Sheldon
well sorry i didnt really answer that very well, its been a long day
If it were me and i havnt really looked at the code,
but here
I would add a mySQL insert scriptPHP Code:
// now let's move the file to its final location and allocate the new filename to it
@move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename)
or error('receiving directory insuffiecient permission', $uploadForm);
// If you got this far, everything has worked and the file has been successfully saved.
// We are now going to redirect the client to a success page.
header('Location: ' . $uploadSuccess);
like this
PHP Code:
// now let's move the file to its final location and allocate the new filename to it
@move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename)
or error('receiving directory insuffiecient permission', $uploadForm);
//in addition to Bokeh's script you can insert each record into a database.
$q = "INSERT INTO table_name (`filename`,`date`) VALUES ('$uploadFilename',$date(dMy))";
$s = mysql_query($q);
//if an error
echo(mysql_error());
// If you got this far, everything has worked and the file has been successfully saved.
// We are now going to redirect the client to a success page.
header('Location: ' . $uploadSuccess);
and to display it would be a simple select script
I suck at this. I'm more than a newbie, I'm a baby. I want to create a webpage that will allow a friend of mine to upload pictures using my website. I have read so much on formhandlers and php that now I am dizzy and even more confused. Is there someone out there that can help me make this webpage along with step by step instructions on how to impliment it. I use frontpage 2003. I also need it to be able to do multiple files. thank you
then dump frontpage and download bokehs multiple upload script and put it in your root dir. It will just work as long as you have php enabled on your server.
I would like the results on the web site...more specifically to show on the page once uploaded.Quote:
Originally Posted by toplisek
I figured that it would have to go into a database, but I am a rookie at databases.
How would I get the pics that were uploaded to view on a page in real-time?
Refer to my post following toplisek's reponse. assuming you konw how to set up a database and have access to a mySQL database. Thats would be the first thing to check.
then you want something like this.
Hi,
OK, the image uploads ok, now I want to stick the filename into an existing row field. I don't get an error and the redirect works after the upload. Also I don't want to insert the whole path just the filename, am I using $uploadFilename ?
My code is:
$regid holds the correct value and so does $uploadFilename as I echo'd them out to test.PHP Code:// If you got this far, everything has worked and the file has been successfully saved.
// We are now going to redirect the client to the success page.
// But first add the image filename to the database
require_once('includes/connect.php');
$regid = $_SESSION['ladyid'];
$sql = "UPDATE femaleusers SET image = '$uploadFilename' WHERE id = '$regid'";
header('Location: ' . $uploadSuccess);
Many thanks if anyone can shed some light on this!
Are you actually running the query, because the the query in your post is followed by header(Location:...) which in therory would cause a user abort.
Yes, thanks.... although now I have the whole path and file name, like 'C:\blah\file.jpg'.
Which variable should I use??
Where are those backslashes coming from?
I thought this was a sticky?
as Bokeh said, You need to run the query before sending them away with a header request.
$_SESSION['ladyid']; ?? what are you building? a porn site?PHP Code:// If you got this far, everything has worked and the file has been successfully saved.
// We are now going to redirect the client to the success page.
// But first add the image filename to the database
require_once('includes/connect.php');
$regid = $_SESSION['ladyid'];
$sql = "UPDATE femaleusers SET image = '$uploadFilename' WHERE id = '$regid'";
mysql_query($sql);//run the query
echo(mysql_error));//echo any errors
header('Location: ' . $uploadSuccess);
The tutorial is sticky and it links to this one.Quote:
Originally Posted by Sheldon
He should post the URL so we can check the code and make sure it is standards compliant!Quote:
Originally Posted by Sheldon
@ALL
Thanks for all the help on this...
Sorry, my mistake when typing... more like C:/blah/file.jpgQuote:
Where are those backslashes coming from?
I've now got the query running, if I put echo(mysql_error));//echo any errors in there I get an error with header('Location... saying header already sent... anyway it DOES now insert the filename in the correct field in the db but I have the whole upload path, I just want file.jpg but couldn't see what variable to use instead of $uploadFilename.Quote:
mysql_query($sql);//run the query
echo(mysql_error));//echo any errors
header('Location: ' . $uploadSuccess);
Hehe... nope, not quite.. its a site for introductions more than anything... the ladies are all Thai.Quote:
$_SESSION['ladyid']; ?? what are you building? a porn site?
Thanks again for all the help....
hi,
I know I haven't looked at this in awhile but I just thought i'd post my solution, simple for a non-newbie but I thought someone might find it useful.
I added an extra variable after the while loop (for giving the file a unique name):
This gives me a variable of just the filename so I can insert it in the image field in the db with the sql query:PHP Code://name var for image
$imagename = $now.'-'.$_FILES[$fieldname]['name'];
Not rocket science but maybe helps someone...PHP Code:$sql = "UPDATE femaleusers SET image = '$imagename' WHERE id = '$regid'";
mysql_query($sql);//run the query