PHP upload only jpg, gif

I 've been working with this file for a day now and I can
upload files but I want the user to be able to upload certain types
of files. Like jpg, gif or pdf. The number of items uploadable are
determined by a previous page submitted. Here is my code any help
would be greatly appreciated.
<?
// start of dynamic form
$uploadNeed = $_POST['uploadNeed'];
for($x=0;$x<$uploadNeed;$x++){
?>
<input name="uploadFile<? echo $x;?>" type="file"
id="uploadFile<? echo $x;?>">
</p>
<?
// end of for loop
?>
<p>
<input name="uploadNeed" type="hidden" value="<? echo
$uploadNeed;?>">
<input name="filename" type="hidden" id="filename" value="
<?
$UploadExts = array('gif','jpeg','jpg');
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$file_name = $_FILES['uploadFile'. $x]['name']['type'];
$file_ext =
strtolower(substr($file_name,strrpos($file_name,".")));
//File Extension Check
if (!in_array($file_ext, $UploadExts))
$file_ext = substr(strtolower(strrchr($file_name,'.')),1);
$copy = copy($_FILES['uploadFile'.
$x]['tmp_name'],$file_name);
else
$message = "Sorry, $file_name($file_type) is not allowed to
be uploaded.";
// check if successfully copied
if($copy){
echo "$file_name | uploaded Successfully!><br>";
}else{
echo "$file_name | Could Not Be Uploaded!<br>";
// end of loop
?>">

im afraid not...
I've been googlin for a solution for this problem for some time, and i got nothing!
All that i got was that there is a property for the "file" html input component that's called "accept" which you can add a list of MIME types that you want to be listed in the upload file dialog... But the funny thing is... Its only in the W3C standard an none of the current browsers support it till now!!!! = |
The only solution that they gave till now, is to use javascript to check the file name value when submitting the form and make sure that the extension is like what you want, else report it in an alertbox for the user that he change the file type cause its not supported! How absurd! =/
If anyone could find a solution for this thing, i'll be happy to know...

Similar Messages

  • Jpg,gif, and gui's

    hey guys, I just started learning to code gui's... but my book is vague about inserting jpg or gif.....
    I was using:
    ImageIcon b = new ImageIcon("board.jpg");
    I keep getting a blank canvas..
    Can someone help me with siimple code for making a gui with just a picture in it
    thx

    @OP...
    1) The convention used in your sample code assumes
    that the image source file is in the executing
    directory or classpath.... if not you will need to
    provide the full path...
    eg: "C:/Some
    Directory/SomeOtherDir/Myimage.jpg/.gif/,png"or in a directory off the root:
    root-
    /images
    /classes
    /com
    /whatever
    Then ImageIcon icon = new ImageIcon("images/myImage.gif"); will load
    >
    2) If the Image is large, (not in size only, btw),
    you need to use an ImageTracker or you could resort
    to the
    Toolkit.getDefaultToolkit().getImage("somePath")
    method to ensure that the Image is loaded to
    completion prior to the gui being rendered.. any
    delays will see the ImageIcon being updated after the
    gui is rendered, naturally producing no image.....
    ImageIcon uses a ImageTracker to load images

  • Import only jpg files from a camera that shoots RAW+jpg?

    Is there a way to import only jpg files from a camera that shoots both RAW+jpg? I only want the small jpgs copied, not the RAW file. I have the USB adapter and am about to go on vacation and wanted to use my iPad to upload pictures to Facebook on the go so I am going to shoot on my Canon 5D in RAW+jpg. All I want to copy to the iPad are the jpg files. Is there a way to only copy one?

    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?
    I would note there is a long-standing issue between Kodaks and some versions of OS X - the workaround for that is to use a USB Card reader.
    Regards
    TD

  • I want only .jpg, Apple wake-up!!!

    I 'm using for family site the pastel theme. My web-space isonly 100Mb and I'm running out of space because most photos are uploaded as they are (over 2Mb each).
    I've searched the whole forum and I've found various tricks (iweboptimizer, export while pressing command button, use photoshop.....); unfortunately they doesn't solve my problem.
    Now, what can I do to force iWeb to use only .jpg format ? I don't use any effects on photo inside the blog.....
    Is make a sense ask Apple to put a simple control, checkbox, that give us the possibility to choose?
    In the meantime, any other suggestion ?
    Please don't tell me to use photoshop or other $$$$ software as I don't have them.
    Last but not least, this time I'm upset with Apple.

    The issue you are having is not really about jpgs or pngs. The real issue is that you haven't properly sized your images for use in iWeb. This is an important step because of two things...1. iWeb's propesity for bloating files because of image effects like rotation, reflections, borders, shadows, etc. and 2. iWeb's insistence on uploading not only images that it has resized but also the full resolution images (what you dragged into iWeb).
    Because of these "flaws" in iWeb, you really do need to prepare images to be used in iWeb. This means not letting iWeb to the resizing because not only will iWeb upload the resized photo but it will also upload the original resolution photo. The secret is to give iWeb photos that are already scaled by some external application...like iPhoto. I personally like one called "Downsize" because it lets me control jpg compression levels and lets me add frames and drop shadows and image masks.
    Yes, these are things that iWeb could do better, perhaps in a later incarnation, but that doesn't mean that we users have to sit still and wait for Apple to solve our problems.

  • Cannot edit JPG, GIF files stored in a SharePoint 2010 picture library

    Created a SharePoint 2010 picture library to store .jpg, .gif images along with other types of images which were created using Adobe photoshop, Tiff etc.
    Upon clicking on the .jpg, .gif files for editing purposes, they open in the browser instead of Photoshop so I cannot edit these files for this reason. Other types of image files are editable but not the jpg, gif files. File associations are already
    in place for these files to open in Photoshop. Please advise.
    Thank you,
    Mahesh

    You can change the default application that opens while you click open document using DocIcon.xml which is present on the web front ends. Please look at this link which explains what you need to update in order to take care of your requirement. 
    http://msdn.microsoft.com/en-us/library/ms463701.aspx
    Hope this helps. 
    Thanks, Mayur Joshi Blog: http://splearnings.blogspot.com/

  • I have made a webpage in HTML with several links to JPGs / GIFs. The text matter opens perfectly but not the images. Please help me

    I have made a web page in HTML with several links to JPGs / GIFs. While text matter opens up perfectly, but not the images. Please help me.
    == This happened ==
    Every time Firefox opened
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CTS Version; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

    URL of that web page?

  • Store/Read JPG/GIF as file on Application server,cluster table/MIME Rpstory

    Hello All ,
    I was trying to build up a ImageStore proxy class to save JPG/GIF in the following ways .
    u2022     File format on Application server with GUID reference / Whenever I need I can read/ archive it with  ID#
    u2022     In cluster table  - Same concept
    u2022     In MIME repository
    I am thinking to use MIME APIs which are already available in SAP system .   Let me know if anyone of you has any good suggestions/tips/tricks to do it .
    BTW I have looked at Thomas Jung  blog as a starting point .
    /people/thomas.jung/blog/2007/09/05/abap-bitmap-image-processing-class
    Thanks.
    Khan

    Solved myself!!! Canu2019t believe.  .. Donu2019t ask how ..Lots of coding involves.

  • Writing jpg/gif to rtf

    Hi all,
    I'm in the dark here. does anyone know how to save a jpg/gif with text to an rtf file???
    I don't know even where to start.
    Thanks
    ppr

    I'm not sure I'm following you.
    I checked
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/rtf/package-summary.html
    but it doesn't say anything.
    The truth is, it doesn't need to be in rtf, but with anything that can save both embeded pictures and text.

  • Possible to upload only Edited images to existing web gallery

    I have a couple of large galleries and after I upload the whole thing I see a couple of edits I need to make.
    How can I upload only selected images with the Web Gallery (I still want my index page to have ALL of the ones in the collection, i just want the updated ones to be reuploaded).
    Rob.

    Thanks for the reply, although I don't like the answer!
    I have a Zenfolio account and an open source Gallery, maybe I will continue using those (using Export Plugins) although I like the Flash galleries (third party) for LightRoom.
    Thanks,
    Rob.

  • How do I upload a JPG or PDF to Adobe Line?

    How do I upload a JPG or PDF to Adbove Line to trace, red line, or comment? If it doesn't allow you to upload a JPG or PDF (thinking engineering drawings) then I would consider this a serious omission.

    Sorry for the delayed response here. Have you tried uploading files to your Creative Cloud account and importing to Line? Creative Cloud supports a wide variety of file formats and creates renditions in the format that is requested by the app.
    Also, there should be no difference between the set of photos accessible to Sketch and those accessible to Line.

  • How to save and retrieve jpg/gif format image in db2

    Here am facing problem to insert jpg/gif format image in my database. And at the same time i would like to know how to retrieve that and how to display that image in my html page. So please help me in this matter.

    In future JDBC questions should be posted into the JDBC Forum

  • MI7.1 Delete the inserted data before sync for the upload only data object

    Hi,
    I have a upload only data which have insert bapi wrapper only. I am able to save the data and insert data but my problem is how to delete the data before it syncr. Is this possible?? Or must i create a delete bapi wrapper??
    Thanks.

    Hi,
    Thanks for you reply. I manage to delete the inserted data refer to the employee_ui sample application but the data still appear at the backend after sync. Any idea why this happen??
    Using the following code i am able to delete the record at the devices. But when it sync the data still get insert to database table.
              ZmovementZmovementheader header = (ZmovementZmovementheader) wdContext.nodeasset_services().nodegetZmovementHeaders().nodegetZmovementHeadersOutput().getCurrentElement().model();                    
              ZmovementZmovementdetail detail = (ZmovementZmovementdetail) wdContext.nodeasset_services().nodegetZmovementDetail().nodegetZmovementDetailOutput().getCurrentElement().model();
              header.removeFromZmovementdetails(detail);
              root.commit();
    thanks
    Edited by: fcgan on Aug 28, 2008 10:17 AM

  • When i save any image from any website then there is no option showing in the save as box like saves as .jpg etc. In this case I manually add the extension of image for example .jpg .gif etc. Please solve my problem :(

    When i save any image from any website then there is no option showing in the save as box like saves as .jpg etc. In this case I manually add the extension of image for example .jpg .gif etc. Please solve my problem :(

    I'm guessing your problem is caused by code validation errors: orphaned division tags for example, or mismatched code and document type (i.e.  XHTML /> mixed with HTML > style closures).
    Start by using the code validation tools below and fix any reported.  You'll need an Internet connection for this:
    HTML Validator - http://validator.w3.org 
    CSS Validator - http://jigsaw.w3.org/css-validator/  
    HTML & CSS Tutorials - http://w3schools.com/
    If this doesn't solve the problem, you will need to post a URL to your live page so we can see your code and images working together.   Or at the very least copy and paste your HTML and CSS code into a reply using double arrows >> Syntax Highlighting > Plain.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • FTP clients/upload only changed pages

    I've been reading all the posts related to uploading sites created with iWeb to a non .Mac acccount using various FTP clients, and just want to make sure I am understanding this correctly. I use Fetch to upload my two sites to a godaddy.com account. No problems, everything works fine. My sites don't have a lot of pages right now, so I don't care that the whole thing is uploaded every time I make a small change or add a new page. But if my site increases in size & takes a long time to upload, I'd like there to be a way to only upload the changed or new pages. Am I correct in thinking that as of now, none of the FTP clients available are able to do that?

    Hi,
    you're right: none of the FTP clients is able to do that with iWeb.
    That's what I think why it is so (yet not 100% sure): FTP clients compare the file size and the date a file was edited. If they see it changed they upload that file. If not they kind of skip it.
    The "problem" now is that when you export an iweb-website to a folder the files are marked as "created the day and time" you exported it. And that's why (I repeat, I'm not 100% sure) the ftp client doesn't skip the files because the answer from the server is "the file on the computer is newer than the file I have".
    (To the pros who read that: please correct me if I'm wrong so that I can learn and don't make mistakes twice...)
    BUT WHAT YOU CAN DO is manually selct the files you want to be uploaded. Say you change something in the index file, you can go to your ftp client select the index file and then upload only the index file (I do that all the time with one or more files).
    If you add pages that do not appear in the nav bar, means that on a page you have links to that pages, in your ftp client you can select the pages you added and the page you inserted the links to those pages and upload only those.
    Now I'm not sure about adding a page that appears in the nav bar, I would try it but my page has a lot of pages and it takes forever to export to folder but you could try... (please tell me the outcome) But I think that it works with those pages too (I think the nav bar will be updated in the whole site even if not re-uploading them all)
    Reagrds,
    Cédric (please someone tell me what I didn't know yet, Thanks!)

  • I can longer place PSD files into Illustrator. Only jpgs are working. I'm using CS4 and Yosemite. What's up?

    I can longer place PSD files into Illustrator. Only jpgs are working. I'm using CS4 and Yosemite. What's up?
    Creative Suites

    THat's a bug/ compatibility issue in Yosemite.
    Mylenium

Maybe you are looking for

  • Migrating an aggregate to new HA pair in cDOT cluster

    We currently have a FAS8020 8.3 cDOT cluster in our DR site, that is currently used for dev/QA storage as well as SnapVault destinations from our production site. We are in the process of migrating over from a FAS3250 at that site that is currently 8

  • Downloaded files? saved files?

    on regular pc as well as my mac mini when i download or save files from the internet to my desktop it instantly appears after the download. (Let say i right click a picture and select save to desktop it will be available for viewing at once when down

  • Two 3G Phones ... One is Getting WiFi and The Other Isn't ... What Gives?

    I am trying to connect a 3G phone to WiFi. When I try with one iPhone 3G, I enter in the password, it connects and then provides service and the connection works properly. I then try doing the same thing with another 3G phone and it appears to connec

  • Getting all metadata (custom & OOTB) for a content

    Hi All, I need to get all the metadata values for a content item in the content server. I tried using DOC_INFO_BY_NAME service and got the result set and I 'm able to retrieve the values by specifying metadata as dataObject.get("dSecutiryGroup"); No

  • Re: Fiori Launchpad Failed load the Group

    Hi, I 've faced with the errors And also I have an error I have SAP_UI SP11 UI5 1.26.11 I've assigned all nessesury roles SAP_UI2_ADMIN_700 SAP_UI2_ADMIN_702 SAP_UI2_ADMIN_731 SAP_UI2_FIORI_CATALOGS_READ SAP_UI2_LAUNCH_PAGE SAP_UI2_NEWS_TILE SAP_UI2_