Silicon Valley MySQL Group Message Board › I'm a Beginner and I just wanna ask you all a question

I'm a Beginner and I just wanna ask you all a question

A former member
Post #: 1
I'm trying to upload images to a site i'm practicing on. i tried a script from the book of julie meloni just revising it a bit:

<?

if($_FILES[img1] !="") {

copy($_FILES['img1']['tmp_name'],
"images/products/Automation/".­$_FILES['img1']['name'])
or die("Could not copy.");

}else{

echo "Try again.";

}

?>


now everytime i click the upload button on the form page, i get a success message but it's never really uploaded...

now i've analyzed a programmer's work to get an idea of how he did his uploading and what he did was basically to upload it to the database. but i can't figure out how to do that using the INSERT script.

hope you can help!

thanks and i'm so glad i found this site...
A former member
Post #: 1
Here's a sample script that I've used...

<?php
$file_dir = "/path/to/upload/directory";

foreach ($_FILE as $file_name => $file_array) {
if (is_uploaded_file($file_array['tmp_name'­])) {
move_uploaded_file($file_array['tmp_name­'], "$file_dir/$file_array[name]")­ or die ("Could not copy file");
echo "file was moved<br />";
}
}
?>

Also, if you haven't already done so, you might want to check with the PHP Meetup groups.

Hope this helps
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy