PHP Upload script for ZIP/SIT files

Hi,
I'm trying to locate a decent script that would allow clients
to upload files to a Web site that I am working on. I found a basic
one that works at www.w3schools.com/PHP/php_file_upload.asp.
However, it lack the capabilities to upload zip and sit files.
Could I modify the existing script that I just mentioned?
Unfortunately, I am not very PHP saavy. I have been Googling for
such a script but have not found one yet. I hope some one could
recommend a decent script. Thanks.

.oO(Mark A. Boyd)
>Carlton Chin posted in macromedia.dreamweaver.appdev:
>
>> I'm trying to locate a decent script that would
allow clients to
>> upload files to a Web site that I am working on. I
found a basic
>> one that works at
www.w3schools.com/PHP/php_file_upload.asp.
>> However, it lack the capabilities to upload zip and
sit files.
>> Could I modify the existing script that I just
mentioned?
>
>The ticket is where the script is checking
$_FILES["file"]["type"].
>See
http://www.w3schools.com/media/media_mimeref.asp
>
>If you only want to allow zip/sit, try changing this:
>
><?php
>if ((($_FILES["file"]["type"] == "image/gif")
>|| ($_FILES["file"]["type"] == "image/jpeg")
>|| ($_FILES["file"]["type"] == "image/pjpeg"))
>&& ($_FILES["file"]["size"] < 20000))
Be careful. These informations can be faked or might not be
available at
all. I can easily upload a PHP script as "image/jpeg". If the
file ends
up in a public directory within the document root, I can
execute it and
then have a look at the entire server ...
Relying on the content type or file extension is a huge
security hole!
I'm quite surprised that W3Schools publishes such an insecure
script.
To make sure that an uploaded file is really of the type you
expect, you
must look at its content! For images you can use
getimagesize(), which
will also return the type if it's a valid image. For other
types you
have to use other libs or external tools. On a *nix machine
you could
execute the shell command 'file' for example, which
recognizes quite a
lot of different file types.
Micha

Similar Messages

  • Sharepoint warmup script for https sites

    we want to warm up https site which is based on sharepoint 2010.
    When we run some sample powershells it shows access forbidden error so we are not able to warm up https site.
    Its slow on first load so need some warmup script for https sites.
    sharepointer

    Just ensure that the service account that you use to trigger the Powershell scripts has access to IIS and SharePoint.  Most often, the SharePoint Farm account would be used for scheduling the warm up scripts on the WFE server.
    I trust that answers your question...
    Thanks
    C
    http://www.cjvandyk.com/blog

  • Need  Shell Script  for picking the files

    Hi,
        I want to write a shell script for piking the files in a sequence order (according to filename with time stamp)  from the sorce FTP server ..
                     Requirement is  in the source directory I'm getting files (Jain_1.xml  , Jjain_2.xml, Jain_3.xml .. ect..)  at  present my file adapter is picking all the files at a time  but  i want to pick  one by one... that to first i want to Jain_1.xml  after finish the processing of the file then only my file adapter should  pick the next file ( Jain_2.xml )  .
                  so..  all the forum mates suggest me to write a shell script..  but where  i have to write the s hell script. and where i have to deploy this script.... my Xi is running on UNIX ... so please sugest me  the procedure ...
    Regards
    Jain

    Hi,
    Why dont you use the option EOIO in which files will be picked up in order and will be proccessed in sequence....one after another....
    Regards,
    Sreeni.

  • Secure login script for my site

    I can not seem to find a idiot proof login script for my
    site, can someone help out PLEASE i'm going in sain!!!
    can not be be that hard or it is?
    thanks for any help.

    Well if you want something really easy to use, and are
    willing to lay down a bit of dough, check out this DW extension.
    http://www.interaktonline.com/Products/Dreamweaver-Extensions/MXUserLogin/Overview/
    I have it, and it's pretty simple to use.

  • Script for zipping + FTP transfer

    Hello all !
    *_My needs :_*
    I would like to zip my video files before sending them through FTP. I would like to use Compressor for all these tasks.
    *_My problem :_*
    I found a script on the internet for zipping, then set my destinations to my FTP server.
    When I compress a file with my settings, it creates a zip version of my file then sends the unzipped version on the ftp server! Dooh ! I understand that my script doesn't tell Compressor to send the zip version of the file.
    Does anyone know how I could make it work ?
    Thank you for your help !

    Don't know how to do all that in compressor, but using Stuffit you can set a watched folder that will zip anything that lands in there and ftp to where ever you like. Just a thought...

  • Transfer script for public sites

    Hi,
    Is there a way for using a transfer script in public sites ?
    I only want to get the content information using a script.
    Thanks

    We're not including the destination variable in the form post that calls our cgi script. I can't get to the Edit Site Settings window in the original iTunes U store - we use this transfer script to handle the admin access, and it isn't working for that either.  I've been testing a very simple version of this Perl script from a fresh copy of the sample files collection, and with debugging enabled it looks like it is getting everything except for a current time - it tells me that the time is valid, but is "too far in the past" and so it doesn't include the otherwise valid identity and credential values.  I'm checking with our system administrators to verify that our server's time is accurate.  Thanks for the follow-up response.

  • A script for copying smilar files to a new location

    Hi,
    i newbies to scripting. My challenge is that I want a script to only copy files with names "similar" and not "exactly the same" as the filenames in the text file.
    For example some files have 10 letters file name like "ABC01FGH01.tif".  I have to copy file where starting letter "ABC" and middle letter "FGH" of file name are fixed, but other letters are changed.
    The script sees a file name like "ABC**FGH**.tif", it should search the source location and copy the files having filenames with at least this characters e.g. "ABC02FGH02.tif", "ABC03FGH04.tif" should be copied since it has
    contains "ABC**FGH**.tif".
    Please help.

    Learn how to use wildcards in file names.  '*' is for any number of characters and'?' is for one character.
    COPY ABC??DE???.?x? c:\target
    Start by using DIR
    DIR ABC??DEF???JK.?x?
    ¯\_(ツ)_/¯

  • Script for moving & deleting files

    Hi
    I'm quite new to scripts & looking for a script to move selected files with time-stamp & also a script to delete selected file/s in a directory. Below is an example of my requirement
    Move
    Ex:  c:\work\source\test.txt to c:\work\target\test.txt_04202015022100
    Delete
    Ex: c:\work\target\test-1.txt
    Could someone help me please.
    Thank very much
    Neil

    This forum is for scripting questions rather than script requests.
    Please start by reading the following:
    Posting guidelines
    Handy tips for posting to this forum
    How to ask questions in a technical forum
    Rubber duck problem solving
    How to write a bad forum post
    Help Vampires: A Spotter's Guide
    -- Bill Stewart [Bill_Stewart]

  • Script for emailing multiple file types?

    Is there a script that will allow me to place a button on a form, that when clicked, will email the completed form in PDF format as well as in csv, or xml format?
    Thanks!

    Wow, thanks. That was extremely helpful, but I have a couple questions.
    First, is there a way to make it print to CUPS without opening the default application for the particular file first? For example, I used a .docx file, and it had to open microsoft word to send the job the print. This makers it very unpredictable to decide how much time the automator application will need to pause. If that file were for example, and adobe illustrator file, it would take an incredible amount of time just for illustrator to open. I don't really anticipate needing to do this a whole lot with anything other than text files and standard image types, but is that the only way for those other files to print? I figured that since OS 10.6 can do a quick look preview on just about any file type I use, that the OS would be able to do this without the application actually opening, but it seems not to be the case. Just wondering.
    The other issue is the only real problem, and it's one that I have had whenever I use automator to make PDFs. It always duplicates the job. So, I am getting a combined pdf, but it has the same file in there 2 or even 3 times.
    In automator, I used:
    get selected finder items
    then
    print finder items
    I have verified that it is printing everything multiple times because I see them going into the CUPS folder twice. Then, the final PDF sometimes even has the same doc or image in it 3 times. I have always had this problem with automator and PDFs, any idea how to solve that?
    Other than that duplication issue, this seems like it will work perfectly! Thanks for the reply here!

  • Error: run postflight script for adobe common files

    error: run postflight script for adobe common files

    I am sorry can you please restate your inquiry.  If you can provide some more details regarding which Adobe Software you are inquiring about?  Which operating system are you using?  Finally what are you trying to accomplish when you receive this error?

  • File upload script not getting the file name for larger files

    Hi
    I have the following code (see extract below) and find that
    when the size of the file to upload is larger than about 300kb the
    code does not grab the file name. Consequently the upload fails.
    The code works fine when the file size is smaller.
    The code in the form page is:
    <form
    action="UploadAttachment.asp?SubjectName=<%=Request.QueryString("SubjectName")%>&VersionN umber=<%=Request.QueryString("VersionNumber")%>&QualificationName=<%=Request.QueryString(" QualificationName")%>"
    method="post" enctype="multipart/form-data" name="form1">
    <input name="file" type="file" size="100">
    <input name="Upload" type="submit" id="Upload"
    value="Upload">
    </form>
    The code in the UploadAttachment.asp page is:
    <%
    'Grab the file name
    Dim objUpload, strPath, SQLString
    Set objUpload = New clsUpload
    'there is a problem that this next line doesn't grab the file
    name if file is too large.
    strFileName = objUpload.Fields("file").FileName
    etc.
    %>
    If you have any idea how to resolve this I'd be grateful.
    Neil

    Hi
    I have the following code (see extract below) and find that
    when the size of the file to upload is larger than about 300kb the
    code does not grab the file name. Consequently the upload fails.
    The code works fine when the file size is smaller.
    The code in the form page is:
    <form
    action="UploadAttachment.asp?SubjectName=<%=Request.QueryString("SubjectName")%>&VersionN umber=<%=Request.QueryString("VersionNumber")%>&QualificationName=<%=Request.QueryString(" QualificationName")%>"
    method="post" enctype="multipart/form-data" name="form1">
    <input name="file" type="file" size="100">
    <input name="Upload" type="submit" id="Upload"
    value="Upload">
    </form>
    The code in the UploadAttachment.asp page is:
    <%
    'Grab the file name
    Dim objUpload, strPath, SQLString
    Set objUpload = New clsUpload
    'there is a problem that this next line doesn't grab the file
    name if file is too large.
    strFileName = objUpload.Fields("file").FileName
    etc.
    %>
    If you have any idea how to resolve this I'd be grateful.
    Neil

  • How to avoid password prompt in shell script for zip password protection

    Hi
    I am trying to set password protection to my oracle database export backup. Once the backup completed, it should compress with a password protection. Thats the plan. Initialy we were using the gzip for the compression. Then realized that there is no password protection for the gzip. Started using zip option. I tried using
    zip -P <password> filename
    But it was throwing below error.
    -bash-3.2$ zip -P expreports REPORTS_2013FEB14.dmp
    zip warning: missing end signature--probably not a zip file (did you
    zip warning: remember to use binary mode when you transferred it?)
    zip warning: (if you are trying to read a damaged archive try -F)
    zip error: Zip file structure invalid (REPORTS_2013FEB14.dmp)
    Not quite sure why.
    Then I used zip -e REPORTS_2013FEB14.dmp.zip REPORTS_2013FEB14.dmp
    But this prompting for the password. As I am trying to put the command in the script. It will be tough if it prompts for the password.
    I would like to know how to avoid the password prompting by saving somewhere or how the code should be written. Tried using expect feature of shell script. Below was the code I tried. It didnt work.
    [oracle@SF40V6636 test]$ cat repexp.sh
    zip -e REPORTS_imp.log.zip REPORTS_imp.log
    expect "Enter password:"
    send "imprep"
    expect "Verify password:"
    send "imprep"
    So please help in avoiding this password prompt or let me know how to change the code.
    Thanks
    SHIYAS M

    How about using gpg and adding a secret key to the requirement of a password? No one should be able to decrypt your file, not by knowing only the password.
    1. Generate a public and private key pair:
    $ gpg --gen-key
    When it shows "We need to generate a lot of random bytes…" open another terminal session and type "dd if=/dev/sda of=/dev/null" to create traffic. When the public and secret key created and signed you can Ctrl-C the dd command.
    To see what you have created:
    $ gpg --list-keys
    2. Encrypt and gzip your stuff:
    $ tar zcf stuff.tgz file_or_folder
    $ gpg recipient "Some Name" encrypt stuff.tgz
    $ rm -f stuff.tgz
    3. Decrypt and extract the archive:
    $ gpg batch yes --passphrase "password" -d stuff.tgz.gpg > stuff.tgz
    $ tar zxvf stuff.tgz
    Again, knowing the password alone will not let anybody decrypt your stuff.

  • Transfer script for private site has stopped working

    We had split our vintage iTunes U site into a new Public site - keeping the original access-controlled content as a 'private' site - a few months ago.  We had a transfer script in place for the original site, which was used to direct users to course materials with specific credentials supplied to control access.  The transfer script has stopped working at some point in recent weeks - we hadn't modified it for a quite a while, so I'm guessing that it has stopped working due to some change in the destination url.  I couldn't find documentation indicating any changes to the transfer script so that it finds the original site rather than the new Public site - the site url in the script is "https://deimos.apple.com/WebObjects/Core.woa/Browse/scu.edu", which will open the new public site.  If anyone has a suggestion for what we might try to get the script working again, it would be much appreciated.

    We're not including the destination variable in the form post that calls our cgi script. I can't get to the Edit Site Settings window in the original iTunes U store - we use this transfer script to handle the admin access, and it isn't working for that either.  I've been testing a very simple version of this Perl script from a fresh copy of the sample files collection, and with debugging enabled it looks like it is getting everything except for a current time - it tells me that the time is valid, but is "too far in the past" and so it doesn't include the otherwise valid identity and credential values.  I'm checking with our system administrators to verify that our server's time is accurate.  Thanks for the follow-up response.

  • Help with newsletter PHP Mail script for mySQL / cron job

    I'm just trying to set up a PHP script to send emails as a cron job.
    It pretty much seems to work, but I can't get it to do two parts.
    The first part is to send the emails, and the second is to send a notification email to the site owner confirming that the emails have been sent.
    The script looks like:
    <?php
    include_once "connect_to_mysql.php";
    $sql = mysql_query("SELECT UserID, Firstname, Email, Newsletter_Received FROM Users WHERE Firstname='test' LIMIT 20");
    $numRows = mysql_num_rows($sql);
    $mail_body = '';
    while($row = mysql_fetch_array($sql)){
      $id = $row["UserID"];
      $email = $row["Email"];
      $name = $row["Firstname"];
      $mail_body = 'Test - please ignore';
        $subject = "Safari Awards Newsletter";
        $headers  = "From:[email protected]\r\n";
        $headers .= "Content-type: text/html\r\n";
        $to = "$email";
        $mail_result = mail($to, $subject, $mail_body, $headers);
      if ($mail_result) {
      mysql_query("UPDATE Users SET Newsletter_Received='1' WHERE Email='$email' LIMIT 20");
      } else {
    ?>
    <?php
    if ($numRows == 0) {
      $subj = "Newsletter Sent";
      $body = "The current newsletter has been sent to everyone.";
         $hdr  = "From:[email protected]\r\n";
         $hdr .= "Content-type: text/html\r\n";
         mail("[email protected]", $subj, $body, $hdr);
    ?>
    Basically with the line
    include_once "connect_to_mysql.php";
    included, it sends the emails as per the SELECT query, but does not send the 'Newsletter Sent' email.
    But if I take out that line, it obviously doesn't send the emails as per the SELECT query, but it does send the 'Newsletter Sent' email.
    Any suggestions on what might need changing in order for it to do both would be much appreciated!
    Thanks.

    Change this line -
    if ($numRows == 0) {
    to this -
    if ($mail_result) {

  • Script for generating XML file ... problem with null values

    Greetings everyone,
    i come here with a question that troubles me for some time now. I have a script which i run from SQLPLUS every now and then to generate an XML file.
    Problem is that data which needs to be in XML is not allways <> NULL and i need to hide those tags that are empty </tag>.
    I will post below my script and if you could help me with it it would be really great!
    Thanks for reading!
    set long 20000000
    set long 20000000
    set linesize 32000
    SET ECHO OFF
    SET TRIMSPOOL on
    SET HEADING OFF
    SET PAGESIZE 50000
    SET VERIFY OFF
    SET FEEDBACK OFF
    SET TERMOUT OFF
    spool C:\test.xml
    set serveroutput on
    begin
      dbms_output.put_line('<?xml version="1.0" encoding="utf-8" ?>');
    end;
    SELECT
    XMLELEMENT("ReportRoot",XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi", 'http://www.w3.org/2001/XMLSchema' as "xmlns:xsd" , '1.0' as "Version",sysdate as "CreationDate",to_char(sysdate,'hh:mm:ss') as "CreationTime",'1524544845' as "id"),
    XMLELEMENT("Porocila",XMLELEMENT("JOLY",(SELECT XMLAGG (XMLELEMENT("RefNrReport",replace('SON'||to_char(ref_ST,'00000'),' ',''))) from access_table_2 where ref_ST = &1),
    XMLELEMENT("ReportDate",sysdate),XMLELEMENT("Labeling",'545254450'),
    (SELECT XMLAGG     (XMLELEMENT("Reportf",
                                                                     XMLELEMENT("access",access),
                                                                     XMLELEMENT("date",date),
                                                                     XMLELEMENT("datep",datep),
                                                                     XMLELEMENT("ModificationInfo",'M'),XMLELEMENT("ModificationReason",modireason)))
                                                 from v_xml_test where id_dok = &1 and ind_print = '1'))))
      .extract('/*')
      from dual
         spool off
    exitNow lets pretend that XMLELEMENT("datep",datep), is sometimes NULL and i do not want to display it.

    may be
    with t as
    select sysdate datep from dual union all
    select null datep from dual
    select xmlagg(xmlelement("Reportf",
                             case when datep is not null then XMLELEMENT("datep", datep)
                             end
      from t

Maybe you are looking for