Jump to content

Question on upload


thenewperson

Recommended Posts

Hey, i was messing around with uploads and iframe. I have a upload.php page and upload-file.php page. The upload.php page contains stuff seen by viewer while upload-file.php contains the testing for the files. The upload works perfectly however im trying to add something for when file exists already. 

 

if file exists show javascript alert

upload-file.php

if(file_exists($file)){
$filefailed = "<script type=\"text/javascript\">alert('This file already exists: Please rename your file');</script>";
echo $filefailed;
}

 

 

Since im using iFrames the code above will execute right away and alert. This is one problem of mine but main one i am trying to do is when i upload a file that exists it does not show. I have tryed using a while loop with variable to count it to 1 than reset it to 0

 

$filecounter = 0
while($firecounter < 1){
if(file_exists($file)){
$filefailed = "<script type=\"text/javascript\">alert('This file already exists: Please rename your file');</script>";
echo $filefailed;
$filecounter++;
}
}

However the only time this alert will show is on the load when iframe loads the test page. It will not alert when i try to upload file that exists already.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.