Jump to content

Recommended Posts

I have the following upload form that I want to be able to browse images only. Is this possible or something I will have to implement through PHP?

 

<form action="image_upload_action.php" method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>

Link to comment
https://forums.phpfreaks.com/topic/51496-upload-form/
Share on other sites

you can 'limit' the file type with the 'accept' attribute of the input

 

eg.

<input type="file" name="upfile" id="upfile" accept="gif,png,jpeg,jpg" />

 

However this is by no means to be trusted - most modern browses ignore it.

 

You could use some javascript to check but that relies on javascript being available...

 

Bottom line is you should ALWAYS check any user input before doing anything with it so I would advise you check this server side.

Link to comment
https://forums.phpfreaks.com/topic/51496-upload-form/#findComment-253882
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.