By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

problem while uploading image.

100+
P: 254
Expand|Select|Wrap|Line Numbers
  1. <table width="85%" height="32" border="0" align="left" cellpadding="0" cellspacing="0">
  2.       <tr valign="bottom">
  3.         <td width="21%" align="left" valign="middle">Caption1</td>
  4.         <td width="20%" align="left" valign="middle"><input name="Image_Name1" type="text" id="Image_Name1" value="" size="15" /></td>
  5.         <td width="15%" align="center" valign="middle">File1: </td>
  6.         <td width="44%" align="left" valign="middle"><input name="File1" type="file" id="File1" value="" size="15" /></td>
  7.       </tr>
  8.       <tr valign="bottom">
  9.         <td width="21%" align="left" valign="middle">Caption2</td>
  10.         <td width="20%" align="left" valign="middle"><input name="Image_Name2" type="text" id="Image_Name2" value="" size="15" /></td>
  11.         <td width="15%" align="center" valign="middle">File2:</td>
  12.         <td width="44%" align="left" valign="middle"><input name="File2" type="file" id="File2" value="" size="15" /></td>
  13.       </tr>
  14.       <tr valign="bottom">
  15.         <td width="21%" align="left" valign="middle"> Caption3</td>
  16.         <td width="20%" align="left" valign="middle"><input name="Image_Name3" type="text" id="Image_Name3" value="" size="15" /></td>
  17.         <td width="15%" align="center" valign="middle">File3:</td>
  18.         <td width="44%" align="left" valign="middle"><input name="File3" type="file" id="File3" value="" size="15" /></td>
  19.       </tr>
  20.       <tr valign="bottom">
  21.         <td width="21%" align="left" valign="middle"> Caption4</td>
  22.         <td width="20%" align="left" valign="middle"><input name="Image_Name4" type="text" id="Image_Name4" value="" size="15" /></td>
  23.         <td width="15%" align="center" valign="middle">File4:</td>
  24.         <td width="44%" align="left" valign="middle"><input name="File4" type="file" id="File4" value="" size="15" /></td>
  25.       </tr>
  26.       <tr>
  27.         <td height="26" align="left" valign="middle">&nbsp;</td>
  28.         <td height="26" colspan="2" align="left" valign="bottom"><input type="submit" name="Upload" value="Upload"/>
  29.             <input type="reset" name="Reset" /></td>
  30.       </tr>
  31.       <tr>
  32.         <td></td>
  33.       </tr>
  34.     </table>
  35.  
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['Upload']))
  2.     {
  3. for($i=1;$i<=4;$i++)
  4.         {
  5.             $_Image_Name.$i=$_POST['Image_Name'.$i];
  6.             $_File_Name.$i=$_POST['File'.$i]['name'];;
  7.             $_File_Size.$i=$_POST['File'.$i]['size'];
  8.             $_File_Type.$i=$_POST['File'.$i]['type'];
  9.             $_Image_Name=$_Image_Dir.$_File_Name.$i;
  10.             $abc=$i;
  11.             if(empty($_File_Name.$i))
  12.             {
  13.                 break;            }
  14.             else
  15.             {
  16.                             move_uploaded_file($_FILES['$_File_Name'.$i]['tmp_name'],$_Image_Name) or die("Could Not Upload".$_File_Name.$i);
  17.                 $_Insert_Image=mysql_query("INSERT INTO image_master VALUES($Page_Id,null, '$Image_Name'".$i.", '$_File_Type'".$i", '$_File_Size'".$i.",'$_Image_Name','$today')");
  18.             }
  19.                     }
  20.  
image file is not uploade. and showing some error as well.

please, if some one can help me!
Dec 26 '07 #1
Share this Question
Share on Google+
4 Replies


Atli
Expert 5K+
P: 5,058
Hi.

Please post your code examples inside [code] tags! It's is barely possible to read without them.

To use uploaded files, you should use the $_FILES super-global rather than the $_POST super-global.

Also, the "$_Image_Name.$i" is most likely causing parse errors.
Try using an array instead.

It would also help to see the errors you are getting.
Dec 26 '07 #2

100+
P: 254
Hi.

Please post your code examples inside [code] tags! It's is barely possible to read without them.

To use uploaded files, you should use the $_FILES super-global rather than the $_POST super-global.

Also, the "$_Image_Name.$i" is most likely causing parse errors.
Try using an array instead.

It would also help to see the errors you are getting.

If you can do some modification to this code then it would be better for me. I am new to php

Thanks
Dec 26 '07 #3

Markus
Expert 5K+
P: 6,050
If you can do some modification to this code then it would be better for me. I am new to php

Thanks
Helping and assisting are the fundamental keys of this forum - people wont just write the code for you.

If you could show us the errors you are getting it woupld be better for us ;)

Also, do what atli said - uploaded files arent passed through the $_POST super-global; $_FILES is where it's at.

:)

markus.
Dec 26 '07 #4

100+
P: 254
Helping and assisting are the fundamental keys of this forum - people wont just write the code for you.

If you could show us the errors you are getting it woupld be better for us ;)

Also, do what atli said - uploaded files arent passed through the $_POST super-global; $_FILES is where it's at.

:)

markus.
Hi

I have done that and code is working fine now.

Now I got one more problem I converted jpeg image to thumbnail. it is working as well but when I click the thumbnail image it is not in openning bigger size as thumbnails images get viewed. Do I need to write some code for that to view the image in bigger size.I don't want to view it in Popup window.

How can I do that?
Dec 27 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.