Forum Moderators: coopster

Message Too Old, No Replies

Something simples

Well i hope it is...

         

PSWorx

1:59 am on Nov 12, 2003 (gmt 0)

10+ Year Member



Ok heres the situation, i have a form which at the moment lets me update the dtails to a database and lets me change the on/off status of a corrosponding box, also i can add and delete info/text boxes at present, my task now is to allow for the user to upload an image appropriate to the box their editing, ive used a snippet of code which has worked previously for me, but, right now, it wont upload the image to the designated file directory, heres the code:

for($z=1;$z<=$finalrow;$z++){
$file_dir="images/aucitems/";
$file_url="itemimage$z";
$imageset="itemimage$z";
if(isset($imageset)){
if(substr($imageset_type, 0, 5)=="image"){
echo"Got this far";
copy($imageset,"$file_dir/$imageset_name")or die("Couldnt copy image");}
echo"imageset: $imageset<br>";
echo"fileurl: $file_url<br>";
echo"filedir: $file_dir<br><br>";}
$udcontent="details$z";
$udshow="showbox$z";
$query="UPDATE gdon_aucitems SET details='$GLOBALS[$udcontent]',showbox='$GLOBALS[$udshow]' WHERE id='$z'";
if(!mysql_query($query,$link)){$dberror=mysql_error();echo "NOTE: $dberror";return true;}}}

Quite simply, all i want is for it to upload the file to the directory images/aucitems/ (At a later date the file names of the origonal image will be edited via the script, but for now, this is where im at) Any ideas, suggestion etc let me know, appreciate the help...

NOTE: the incramented variable $z is required as there are multiple image inputs on the form, this area (the for statement, loops through each set of details appending the correct number to the set its currently updating, thought id add that as ive had all sorts of questions from previous help with regards to how im using loops) Also i have a set of echo statements reporting back the values of the vars used for the code related to the image upload, just incase that caused a pause for thought...!

Mr Davidson

Birdman

3:15 am on Nov 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The starting point is the error you are recieving.

I tend to use is_uploaded_file() rather than copy.

See PHP Image Functions [php.net] for more.

Birdman

PSWorx

4:10 am on Nov 12, 2003 (gmt 0)

10+ Year Member



Right i may have tackled the problem here, my own fault for not paying attention to what i was doing, i didnt know what to do with ur post but i did have a look n read some of the posts on php.net, as im new to php tho i find alot of the links passed to me rather un-usable with my current knowledge, none the less, the problem was i wasnt accessing the variable globaly (as it isnt passed thru the functions argumet due to the fact of multiple variables of the same type, ie. itemimage1, itemimage2 etc). I'm going to press on with this and get it working as its the last hurdle of this project...

Thanks tho for your help, i think i need some sleep...