NEWBIE: File upload problems 
Author Message
 NEWBIE: File upload problems
Please help,
I am trying to create an upload script for my site.  It was working fine
before, but now I have turned register globals off it will no longer work.
In my *wisdom* I thought that it would be the same as most other pages with
variables ie $varname=$_POST['varname'] but this doesn't work.  Can somebody
help me please this is driving me mad.  As I say it was working before but I
really need register globals turned off for my new host.
Here is a snippet of my code:
-----------------------
form.php
-----------------------
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
  <p>
   <input name="ID" type="hidden" value="<?php echo "$ID" ?>">
 <input type="hidden" name="MAX_FILE_SIZE" value="524288">
    <input type="file" size="60" name="image">

  </p>
  <p>
    <input type="submit" value="upload">
  </p>
</form>

--------------------
upload.php
--------------------
<?php
mysql_query("UPDATE tblindividual SET Picture= 'pictures/$image_name' WHERE
individual='$ID'", $db);
copy($image, "c:\webserver\Apache2\htdocs\bewick\pictures\\$image_name");
echo "Picture Added"
?>
--------------------
Thanks



Fri, 15 Jul 2005 22:02:10 GMT  
 NEWBIE: File upload problems

Quote:

> --------------------
> upload.php
> --------------------
> <?php
> mysql_query("UPDATE tblindividual SET Picture= 'pictures/$image_name' WHERE

'pictures/$_FILES[image][name]'

Quote:
> individual='$ID'", $db);
> copy($image, "c:\webserver\Apache2\htdocs\bewick\pictures\\$image_name");

pictures\\$_FILES[image][name]"

Quote:
> echo "Picture Added"

http://www.php.net/manual/en/features.file-upload.php

Cheers,

--
Andy Jeffries
Linux/PHP Programmer
http://www.andyjeffries.co.uk/

- Windows Crash HOWTO: compile the code below in VC++ and run it!
main (){for(;;){printf("Hung up\t\b\b\b\b\b\b");}}



Fri, 15 Jul 2005 22:37:31 GMT  
 NEWBIE: File upload problems


Quote:

> > --------------------
> > upload.php
> > --------------------
> > <?php
> > mysql_query("UPDATE tblindividual SET Picture= 'pictures/$image_name'
WHERE

> 'pictures/$_FILES[image][name]'

> > individual='$ID'", $db);
> > copy($image,

"c:\webserver\Apache2\htdocs\bewick\pictures\\$image_name");

Quote:

> pictures\\$_FILES[image][name]"

> > echo "Picture Added"

Thanks for that, however it isn't working.  In mySQL it now has
"pictures/Array[name]" instead of pictures/photo.jpg.

Any ideas why this might be?

Quote:
> http://www.php.net/manual/en/features.file-upload.php

I had a look at that, but I'm afriad a lot of it just went straight over my
head :-( I really need to learn more I think.


Fri, 15 Jul 2005 23:12:24 GMT  
 NEWBIE: File upload problems
My code now looks like:
-----------------
upload.php
-----------------
<?php
$ID=$_POST['ID'];
$image=$_POST['image'];
mysql_query("UPDATE tblindividual SET Picture=
'pictures/$_FILES[image][name]' WHERE individual='$ID'", $db);
//the absolute location of where you want to upload it
//the directory must be chmoded 777
copy($image,
"c:\webserver\Apache2\htdocs\bewick\pictures\\$_FILES[image][name]");
echo "Picture Added"
?>
------------------

Thanks



Fri, 15 Jul 2005 23:17:04 GMT  
 NEWBIE: File upload problems
My code now looks like:

-------------------
upload.php
-------------------
<?php
$ID=$_POST['ID'];
$image=$_POST['image'];
mysql_query("UPDATE tblindividual SET Picture=
'pictures/$_FILES[image][name]' WHERE individual='$ID'", $db);
copy($image,
"c:\webserver\Apache2\htdocs\bewick\pictures\\$_FILES[image][name]");
echo "Picture Added"
?>
------------------

Thanks



Fri, 15 Jul 2005 23:19:27 GMT  
 NEWBIE: File upload problems

Quote:

> My code now looks like:

OK, try this:

Quote:
> -------------------
> upload.php
> -------------------
> <?php
> $ID=$_POST['ID'];
> $image=$_POST['image'];

$name = $_FILES['image']['name'];

Quote:
> mysql_query("UPDATE tblindividual SET Picture=
> 'pictures/$_FILES[image][name]' WHERE individual='$ID'", $db);

'pictures/$name' ...

Quote:
> copy($image,
> "c:\webserver\Apache2\htdocs\bewick\pictures\\$_FILES[image][name]");

... pictures\\$name");

Cheers,

--
Andy Jeffries
Linux/PHP Programmer
http://www.andyjeffries.co.uk/

- Windows Crash HOWTO: compile the code below in VC++ and run it!
main (){for(;;){printf("Hung up\t\b\b\b\b\b\b");}}



Fri, 15 Jul 2005 23:25:54 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. File Upload Problems with binary files (ASCII works ok)

2. Uploading Data from BASIC file Problem

3. file upload-problem: my computer sometimes blocks

4. file upload problem

5. file size upload problem

6. PHP Expert needs help with file upload problem: permission denied

7. Problem while uploading a binary file using cgi module

8. File Upload Problems

9. Problem with file upload

10. Solved: problem uploading large files after RH 8.0 upgrade

11. file uploading - charset problems

12. file upload problem

 

 
Powered by phpBB® Forum Software